Pagination
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
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.
Page-Based Pagination
All array-returning ProducerSync API v1 endpointss 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)