Guides
DocumentationLog In

Pagination

Overview

curl https://api.coinbase.com/v2/accounts \
  -H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c'

Example response

{
  "pagination": {
    "ending_before": null,
    "starting_after": null,
    "limit": 25,
    "order": "desc",
    "previous_uri": null,
    "next_uri": "/v2/accounts?&limit=25&starting_after=5d5aed5f-b7c0-5585-a3dd-a7ed9ef0e414"
  },
  "data": [
    ...
  ]
}

All GET endpoints which return an object list support cursor based pagination with pagination information inside a pagination object. This means that to get all objects, you need to paginate through the results by always using the id of the last resource in the list as a starting_after parameter for the next call. To make it easier, the API will contruct the next call into next_uri together with all the currently used pagination parameters. You know that you have paginated all the results when the response's next_uri is empty. While using cursor based pagination might seem weird compared to many APIs it protects from the situation when the resulting object list changes during pagination (new resource gets added or removed).

Default limit is set to 25 but values up to 100 are permitted. Due to permissions and access level control, the response list might in some cases return less objects than specified by the limit parameter. This is normal behaviour and should be expected.

The result list is in descending order by default (newest item first) but it can be reversed by supplying order=asc instead.

Arguments

ParameterDescription
limit optionalNumber of results per call. Accepted values: 0 - 100. Default 25
order optionalResult order. Accepted values: desc (default), asc
starting_after optionalA cursor for use in pagination. starting_after is an resource ID that defines your place in the list.
ending_before optionalA cursor for use in pagination. ending_before is an resource ID that defines your place in the list.