Pagination

Continuation Token Pagination

In v2 ProducerSync API endpoints, pagination is handled using continuation tokens returned in the links object 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 embedded key
  • a links object, including a next URL 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 embedded object
  • the links.next.href will include a continuationToken=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 page object and a links object to help navigate between pages.

Page Object

The page field provides details about the current page of results.

FieldDescription
sizeThe number of elements returned on the current page (default is 250)
totalElementsThe total number of elements for the search across all pages
totalPagesThe total number of pages for the search
numberThe 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 the page.size response value
  • number: The page number (zero-indexed) --> directly impacts the page.number response value

The links field helps you navigate through pages of results.

FieldDescription
firstLink to the first page of results
selfLink to the current page of results
nextLink to the next page of results
lastLink to the last page of results
prevLink 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 next link to reliably paginate through results
  • Avoid hardcoding page numbers; use provided links instead
  • Be sure to handle the case where no next link is present (end of results)