Pagination

In this guide, we will look at how to work with paginated responses when querying the InvoiceAhoy API. By default, all responses limit results to 10. However, you can go as high as 100 by adding a take query parameter to your requests. If you are using one of the official InvoiceAhoy API client libraries, you don't need to worry about pagination, as it's all being taken care of behind the scenes.

When an API response returns a list of objects, no matter the amount, pagination is supported. In paginated responses, objects are nested in a data attribute and have a results attribute that indicates the number of results returned. You can use the skip and take query parameters to browse pages.

Example

In this example, we request the page that starts at the 11th record. As a result, we get a list of three invoices and can tell by the results attribute that we have reached the end of the result set.

  • Name
    skip
    Type
    number
    Description

    The number of records to skip in the result set. If skip=10, then the result set will start at record 11.

  • Name
    take
    Type
    number
    Description

    The number of results to return. If the number of returned results is smaller than the take value, then you have reached the last page of the result set.

Manual pagination using cURL

curl -G https://api.invoiceahoy.com/v1/invoices \
  -H "Authorization: Bearer {token}" \
  -d skip=10 \
  -d take=10

Paginated response

{
  "results": 3,
  "skip": 10,
  "data": [
    {
      "id": "WAz8eIbvDR60rouK",
      // ...
    },
    {
      "id": "hSIhXBhNe8X1d8Et"
      // ...
    },
    {
      "id": "fbwYwpi9C2ybt6Yb"
      // ...
    }
  ]
}

Was this page helpful?