Pagination
Different APIs use different pagination strategies:
| API | Style | Collection key | Pagination metadata |
|---|---|---|---|
| Contracting API | Page-based | _embedded | page object + _links |
| Hierarchies API | Page-based | _embedded | page object + _links |
| Producer Profile API | Page-based | _embedded | page object + _links |
| ProducerSync API v1 | Page-based | embedded | page object + links |
| ProducerSync API v2 | Continuation token | embedded | links.next only |
Contracting, Hierarchies & Producer Profile APIs — Page-Based Pagination
All collection endpoints in the Contracting, Hierarchies, and Producer Profile APIs return results using page-based pagination. Results are in _embedded, navigation links are in _links, and metadata is in page.
Empty collections: When a collection endpoint returns no results,
_embeddedis absent from the response entirely — it is not an empty object.
Example response:
{
"_embedded": {
"carriers": [ { ... }, { ... } ]
},
"_links": {
"self": { "href": "/v1/customers/carriers?page=0&size=250" },
"next": { "href": "/v1/customers/carriers?page=1&size=250" },
"last": { "href": "/v1/customers/carriers?page=7&size=250" }
},
"page": {
"size": 250,
"totalElements": 150,
"totalPages": 1,
"number": 0
}
}
| Field | Description |
|---|---|
_embedded | Results keyed by resource type (e.g., carriers, products) |
_links | Navigation links — self always present; next, prev, first, last appear when applicable |
page.totalElements | Total records across all pages |
page.totalPages | Total number of pages |
page.number | Current page index (0-based) |
Query parameters:
| Parameter | Default | Description |
|---|---|---|
page | 0 | Page index (0-based) |
size | varies | Default differs by endpoint — always set this explicitly |
Iterating all pages (Python):
def paginate(access_token, base_url, path):
"""Generic HAL+JSON paginator for Contracting, Hierarchies, and Producer Profile API collections."""
results = []
url = f"{base_url}{path}"
while url:
response = requests.get(url, headers={"Authorization": f"Bearer {access_token}"})
response.raise_for_status()
data = response.json()
for items in data.get("_embedded", {}).values():
results.extend(items)
next_href = data.get("_links", {}).get("next", {}).get("href")
if next_href:
# Contracting API endpoints are inconsistent: some return absolute URLs,
# others return relative paths. Handle both.
url = next_href if next_href.startswith("http") else f"{base_url}{next_href}"
else:
url = None
return results
Use page.totalElements to validate you received all expected records.
ProducerSync API v2 — Continuation Token Pagination
In v2 ProducerSync API endpoints, pagination is handled using continuation tokens returned in the
linksobject of the response. This method is ideal for efficiently paging through large datasets.
First Page
Your initial request will return a response:
- containing set of results under the
embeddedkey - a
linksobject, including anextURL for retrieving the next page
Note: The ProducerSync API uses
embedded(no underscore). This differs from the Contracting API, which uses_embeddedper the HAL+JSON standard. If you are integrating both APIs, make sure your code handles each key name separately.
Example Response:
{
"embedded": {
"licenses": [
{ ... },
{ ... }
]
},
"links": {
"self": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=0"
},
"next": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=11862929"
}
}
}
Iterating with links.next
To retrieve the next page of results, follow the URL provided in the links.next.href field:
GET https://access.agentsync.io/v2/licenses?continuationToken=11862929
Repeat this pattern with each subsequent response until the end of the dataset is reached.
End of Results
When you've reached the final page:
- the response will NOT include an
embeddedobject - the
links.next.hrefwill include acontinuationToken=0
Example Final Response:
{
"links": {
"self": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=11862929"
},
"next": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=0"
}
}
}
Optional: Controlling Page Size
You may pass a size query parameter to control how many results are returned per page (default = 250)
- Minimum: 1
- Maximum: 1000
GET /v2/licenses?size=500
Adjusting the page size will impact the number of continuation tokens required to page through the data.
No Results Case
If your query yields no results at all, the response will look like this:
{
"links": {
"self": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=0"
},
"next": {
"href": "https://access.agentsync.io/v2/licenses?continuationToken=0"
}
}
}
Ensure your integration handles this scenario gracefully.
ProducerSync API v1 — Page-Based Pagination
All array-returning ProducerSync API v1 endpoints use page-based pagination. The pagination metadata is included in the response using a
pageobject and alinksobject to help navigate between pages.
Page Object
The page field provides details about the current page of results.
| Field | Description |
|---|---|
size | The number of elements returned on the current page (default is 250) |
totalElements | The total number of elements for the search across all pages |
totalPages | The total number of pages for the search |
number | The zero-based index of the current page (i.e., 0 represents the first page, default is 0) |
Example:
"page": {
"size": 3,
"totalElements": 476944,
"totalPages": 158982,
"number": 0
}
Customizing Pagination
You can customize pagination by setting the optional query parameters:
size: The number of results per page --> directly impacts thepage.sizeresponse valuenumber: The page number (zero-indexed) --> directly impacts thepage.numberresponse value
Links Object
The links field helps you navigate through pages of results.
| Field | Description |
|---|---|
first | Link to the first page of results |
self | Link to the current page of results |
next | Link to the next page of results |
last | Link to the last page of results |
prev | Link to the previous page of results |
Example:
"links": {
"first": {
"href": "http://api.agentsync.io/v1/addresses?page=0&size=3"
},
"self": {
"href": "http://api.agentsync.io/v1/addresses?page=0&size=3"
},
"next": {
"href": "http://api.agentsync.io/v1/addresses?page=1&size=3"
},
"last": {
"href": "http://api.agentsync.io/v1/addresses?page=158981&size=3"
}
}
Best Practices
- Use the
nextlink to reliably paginate through results - Avoid hardcoding page numbers; use provided
linksinstead - Be sure to handle the case where no
nextlink is present (end of results)