Pagination
What is pagination and how does it work
Endpoints which return an extensive list of objects use pagination
Pagination allows the user to request a part of the list, receiving an array of results, next, previous and count parameters in the response. This allows the response to be faster and more precise.
You can use this call to test it (add your token):
curl --location 'https://api.modo.energy/public/v1/frequency?date_from=2023-03-07&date_to=2023-03-07&limit=1000&offset=2000' \
--header 'X-Token: <your_token>'
Here is an example answer:
{
"count": 3291,
"next": "https://api.modo.energy/public/v1/frequency?date_from=2023-03-07&date_to=2023-03-07&limit=1000&offset=3000",
"previous": "https://api.modo.energy/public/v1/frequency?date_from=2023-03-07&date_to=2023-03-07&limit=1000&offset=1000",
"results":
Here is an example code on how to use Pagination and Pandas dataframes on Python:
Answer Parameters
The answer will have four particular parameters:
Parameter | Description |
---|---|
count | How many data points this request has in its entirety, regardless of pagination |
next | The URL of the request to be done to provide the next page of the request |
previous | The URL of the request to be done to provide the previous page of the request |
results | Where the data request will be located |
Request Parameters
Alternatively, you can see that the pagination URL is constructed in a specific manner. At the end of the URL two new parameters are added:
Name | Description |
---|---|
Limit | The number of data points to be on each page. Default: 1000 Maximum: 10000 |
Offset | By which datapoint the page will start. This can be any number as long as it is smaller than the number of data points on the dataset |
That means you can also construct your page structure, if you prefer, by adding these two parameters in the URL to fit your purpose.
Updated about 1 year ago