Offset-based pagination for navigating large result sets in the ADP API
Pagination
The ADP API uses offset-based pagination to navigate large result sets efficiently.
Pagination Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | Int | 25 | Maximum items to return per page |
offset | Int | 0 | Number of items to skip |
Pagination Formula
Page N: offset = (N - 1) × limit
| Page | Limit | Offset | Items Returned |
|---|---|---|---|
| 1 | 10 | 0 | 1-10 |
| 2 | 10 | 10 | 11-20 |
| 3 | 10 | 20 | 21-30 |
Connection Structure
ADP API uses a custom Connection structure WITHOUT the standard
nodewrapper.
Standard GraphQL Connection (NOT used by ADP API)
lineitems {
edges {
lineitem_id
lineitem_name
}
pageInfo {
hasNextPage
}
}ADP API Connection (actual structure)
lineitems {
edges {
lineitem_id
lineitem_name
}
total_count
}Key Differences:
- ✅ Items in
edgesarray (same as standard) - ❌ NO
nodewrapper (different from standard) - ✅
total_countfield (instead ofpageInfo) - ✅
snake_casenaming (not camelCase)
Examples
First Page (Items 1-10)
query GetFirstPage {
dream_adserver {
lineitems(limit: 10, offset: 0) {
edges {
lineitem_id
lineitem_name
}
total_count
}
}
}Second Page (Items 11-20)
query GetSecondPage {
dream_adserver {
lineitems(limit: 10, offset: 10) {
edges {
lineitem_id
lineitem_name
}
total_count
}
}
}Calculate Total Pages
const limit = 10;
const totalCount = 142; // From response.total_count
const totalPages = Math.ceil(totalCount / limit); // = 15 pagesCommon Mistakes
❌ WRONG: Using
nodewrapperlineitems { edges { lineitem_id } }✅ CORRECT: Direct access in edges
lineitems { edges { lineitem_id } }
❌ WRONG: camelCase
totalCountlineitems { totalCount }✅ CORRECT: snake_case
total_countlineitems { total_count }
Best Practices
- Use
total_countto calculate total pages before pagination - Combine with
sortfor consistent ordering across pages - Keep
limitreasonable (25-100 items) for performance - Cache results when possible to reduce API calls
Complete Example
query GetPaginatedLineitems($filter: JSON, $sort: JSON, $limit: Int, $offset: Int) {
dream_adserver {
lineitems(
filter: $filter
sort: $sort
limit: $limit
offset: $offset
) {
edges {
lineitem_id
lineitem_name
lineitem_type
}
total_count
}
}
}Variables:
{
"filter": {"lineitem_is_archived": {"=": false}},
"sort": {"lineitem_id": "desc"},
"limit": 10,
"offset": 0
}Next Steps
- Review Filtering operators
- Understand Sorting requirements (lowercase!)
- Explore Delivery APIs for real-world usage
