Pagination

In this guide, we will look at how to work with paginated responses when querying the VDH-Solar API. By default, all responses limit results to ten. However, you can go as high as 100 by adding a limit parameter to your requests. If you are using one of the official VDH-Solar 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 links attribute that provides you information about the pagination. You can use the links.next and links.prev query parameters to browse pages.

Example using cursors

In this example, we request the a list of products. As a result, we get a list of 10 products and can tell by the links attribute if we've reached the end of the pagination. If the links.next attribute is null, you are at the end of the list.

  • Name
    limit
    Type
    integer
    Description

    Limit the number of items returned. Default is 10 and you can go as high as 100.

  • Name
    page
    Type
    integer
    Description

    The page within the paginated list. Default is 1.

Manual pagination using cURL

curl -G https://vdh-solar.nl/api/v1/products \
  -H "Authorization: Bearer eyJ..." \
  -H "Accept: application/json" \
  -d page=1 \
  -d limit=10

Paginated response

{
  "links": {
    "first": "https://beta.vdh-solar.nl/api/v1/test?page=1",
    "last": "https://beta.vdh-solar.nl/api/v1/test?page=546",
    "prev": null,
    "next": "https://beta.vdh-solar.nl/api/v1/test?page=2",
  },
  "data": [
    {
      "id": 12345,
      // ...
    },
    // ...
  ]
}

Was this page helpful?