Pagination
Endpoints that list resources, such as customers, invoices or wallet transactions, return their results in pages rather than all at once, which keeps every response fast and predictable however many records your account holds. Every list endpoint uses the same cursor-based pagination, so the code your integration uses to page through one resource works for every other resource in the API.
How pagination works
Your integration requests a page and sets how many records it should contain with limit. Each response includes a next_cursor that marks where the following page begins, and sending that value back as cursor returns the next page, continuing until the response reports that there are no more records to fetch.
Reading a page
A list response contains the page of records in a data array and the details needed to continue in a meta object, alongside the message described in Requests and responses.
Fetching a complete list
To retrieve every record, request the first page without a cursor, then send the next_cursor from each response with the following request until has_more is false. Any filters, such as an invoice status, should be sent unchanged with every request, so that each page continues the same list.
Working with cursors
- Treat cursors as opaque
Send a cursor back exactly as it was returned, without building, storing or altering one, since its format may change. A cursor that cannot be read returns the first page rather than an error, so a mistake in handling cursors shows up as the same records being returned again. - Expect records to move
Lists are returned newest first, so records created while you are paging can move earlier records onto later pages, and the same record may appear twice. Use each record’s identifier to recognise any you have already processed. - Use the largest page you need
Requesting up to 100 records at a time reduces the number of requests needed to retrieve a long list and keeps you well within your rate limits.
Pagination is the right way to retrieve records in bulk, such as during an initial import or a periodic reconciliation, while changes that happen after that point are best received as they occur, by configuring a webhook and updating your records from events rather than paging through the same lists repeatedly.