Overview
You can paginate any List
endpoint. Pagination means you can limit the number of total results.
Query Parameters
Parameter | Description |
---|---|
pageSize | how many results to return per page |
page | the current page of the results |
For example, this curl command returns the first page of 50 items per response:
`curl -X GET -H 'X-Adzerk-ApiKey:<APIKEY>' -H 'Content-Type=application/json' https://api.kevel.co/v1/site?pageSize=50`
This returns the second page of 25 items per response:
`curl -X GET -H 'X-Adzerk-ApiKey:<APIKEY>' -H 'Content-Type=application/json' 'https://api.kevel.co/v1/site?pageSize=25&page=2'`
Recommended pagination approach
When working with Kevel APIs in an integration, we recommend adding the following parameters to any LIST endpoint:
pageSize=100
(or other preferred number)page=1
Increment page number to 2, 3, etc. When you get an empty set (eg, no advertisers returned) you know you have reached the end of the list.
A response with an empty list will look like this:
{
"page": 6,
"items": [...]
}
A response with a not empty list will look like this:
{
"page": 2,
"items": [
{
"IsActive": false,
"Created": "2023-04-19T21:11:30.310Z",
"Title": "Tester",
"IsDeleted": false,
"LastModified": "2023-04-19T21:11:30.310Z",
"Version": 1,
"Id": 77545
...
Deprecated list parameters
Legacy Kevel customers will also see pageSize
, totalPages
, and totalItems
parameters in list responses. These are deprecated for newer Kevel API users.
{
"page": 1,
"pageSize": 500,
"totalPages": 1,
"totalItems": 4,
"items": [
{
...
SDK Example
const Adzerk = require('@adzerk/management-sdk');
const apiKey = process.env.ADZERK_API_KEY;
async function listFlights() {
let specifications = await Adzerk.fetchSpecifications();
let client = await Adzerk.buildClient({apiKey, specifications, logger});
let flights = await client.run("flight", "list", {pageSize: 500, page: 2});
console.log(flights);
}
listFlights();
NOTE
The JavaScript Management SDK defaults to a page size of 500.