API Development 101

Pagination

Learn about pagination and how Square endpoints paginate results.

What is pagination?

Some API endpoints paginate their responses to make the result set easier to handle. For example, if you request a list of objects that is potentially too large to handle efficiently, the endpoint will return the first batch of results along with a marker of some kind to access the next batch of results. The pagination marker could be:

  • A token or cursor that you include in subsequent requests to the endpoint either as a URL parameter or in the header of your request.
  • Standardized url parameters to indicate the current starting point, such as &page=3 or &start=100.
  • A link to a different URL for subsequent requests . The new URL usually has a token or URL parameter baked into it.

You may be able to avoid dealing with pagination by narrowing your initial request. Many APIs let you query for results based on specific criteria. For example, the ListTransactions endpoint lets you query for transactions based on time ranges. Requesting smaller result sets can potentially eliminate pagination in the return set and minimize the need for filtering results in your application. Working with smaller result sets can improve application response time and provide a performance boost for your application.

Prev
< Idempotency
Next
Webhooks >

Ask for help on Stack Overflow or join our Slack channel