Pagination

All endpoints responsible for the retrieval of a list of elements take two optional parameters:

  • limit - positive integer to limit the number of elements per page
  • offset - positive integer which allows the pagination to happen

By default, the pagination is set to limit = 10 and offset = 0. The limit cannot exceed 50 for performance reasons. So if you want to get all of your items, you have to adjust the offset accordingly and make several calls.

For example, let's consider having 100 agreements in total to be paginated and showing 10 elements per page.

In this case, the total number of pages is 10, and paginating the response may look like this:

  • page 1 - api/v3/agreement/?limit=10&offset=0
  • page 2 - api/v3/agreement/?limit=10&offset=10
  • ...
  • page 10 - api/v3/agreement/?limit=10&offset=90

The complete request

import requests

url = "https://platform-api.wastehero.io/api/v3/agreement/"

headers = {
    "accept": "application/json",
  	"content-type": "application/json",
    "X-API-Key": "<YOUR-API-KEY-HERE>"
}

params = {
	"limit": 10,
	"offset": 20
}

response = requests.get(url, params=params, headers=headers)

print(response.json())
curl --request GET \
     --url 'https://platform-api.wastehero.io/api/v3/agreement/?limit=10&offset=20' \
     --header 'X-API-Key: <YOUR-API-KEY-HERE>' \
     --header 'accept: application/json'

And the response

{
  "items": [
    {},
    ...,
    {}
  ],
  "total": 100,
  "limit": 10,
  "offset": 20,
  "has_next": true,
  "has_previous": true
}