Skip to main content

Pagination

List operations in the Nodu API, such as List all transfers, return their results one page at a time. They share two request parameters and three response fields. Each list operation in the reference shows whether it takes these parameters.

Request a page​

ParameterMeaning
limitHow many objects to return, from 1 to 100. The default is 10.
cursorThe position to continue from. Send the nextCursor value of the previous response. Leave it out to get the first page.

Nodu refuses a limit outside this range with a 422 validation error.

For example, this call returns up to 50 transfers:

curl 'https://api.sandbox.nodu.fi/v1/transfers?limit=50' \
--header 'Authorization: Bearer <your-api-key>'

Most lists also accept filters, such as customerId. The reference lists the filters of each operation.

Read the response​

FieldMeaning
dataThe objects of this page, as an array.
totalThe number of objects that match the request, across all pages. It is not the size of this page.
nextCursorThe cursor of the next page. The response contains it only when there are more results.

On the last page the response has no nextCursor field. Treat a null value in the same way.

Order of results​

A paginated list returns the most recently created objects first. No parameter changes the order.

Read all pages​

  1. Send the request without cursor.
  2. Process the objects in data.
  3. If nextCursor is present and is not null, send the request again with cursor set to that value. Keep limit and every filter the same.
  4. Repeat steps 2 and 3. Stop when nextCursor is absent or null.

Three rules keep the loop correct:

  • Send a cursor back exactly as you received it. Do not build a cursor and do not change one.
  • Stop when nextCursor is absent or null, not when you have counted total objects. total can change while you read, because objects are created in the meantime.
  • Objects created after you started are at the beginning of the list. If you have already read the first page, the remaining pages do not include these new objects. Start again from the first page to read them.

Next steps​