Pagination
The Api uses pagination for some endpoints. API pagination is a way to break large amounts of retrieved data into smaller, more manageable chunks. The Api uses two different styles of pagination: one with pagenumber and one with cursor.
How to use pagination
Pagination via pageNumber:
Use this kind of pagination if you need to request a smaller volume of data that you want to apply sortorder in some way.
This method is great if you searching for a specific company and want to find the most relevant one for example. Another use case is if you want to fetch for example the top 100 companies of a specific search you have done.
Note
Please note that you probably have a limited search quota. So don't request more companies than necessary in the setup phase. Read more about the Search Quota
Fields:
"pageNumber": 1, # Default is 1, maxlimit is 10. "pageSize": 10, # Default is 10, maxlimit is 500. "sortByColumn": "Valu8Id", # If the field if omitted, it uses a relevence Search. "sortByDirection": "Asc", # Default is "Asc", alternative option is "Desc"
This means that if you have more than 5 000 companies in your search results and want to fetch them all, you will need to use the other pagination method, cursor.
PageSize can be max 500 and PageNumber can be max 10, otherwise you will receive a HTTP 400 response.
{
"parameters": {
"countryCode": [
"SE"
],
"NetSales":[
"250000000"
]
},
"currency": "SEK",
"pageNumber": 1,
"pageSize": 10,
"sortByColumn": "NetSales",
"sortByDirection": "Desc"
}
Pagination via cursor:
Use this kind of pagination if you need to iterate larger volume of data.
Start the iteration by setting the parameter Cursor to value *
In the response you will receive a header called x-pagination. Use the received value as the input for the Cursor-attribute in the next request to continue the iteration. IE use the value of cursor from the latest response/ x-pagination in the upcoming requests to cursor, each time.
The cursor has a restriction to query up to a maximum of 100 000 items. If this is exceeded, then a HTTP-status of 400 will be given in the response. If you have a need to perform a search which exceeds 100 000 items, then you need to use Batches instead, see section about Batches.
To iterate through all responses using cursor, you have to keep iterating until you receive an empty list or until you receive a HTTP-status of 400 (IE you then have iterated over 100 000 items).
Fields:
"pageSize": 10, # Default is 10, maxlimit is 500.
"cursor": "*",
Example for the first iteration:
{
"parameters": {
"countryCode": [
"SE"
],
"NetSales":[
"250000000"
]
},
"currency": "SEK",
"pageSize": 10,
"cursor": "*"
}
Example of iteration 2 and beyond.
{
"parameters": {
"countryCode": [
"SE"
],
"NetSales":[
"250000000"
]
},
"currency": "SEK",
"pageSize": 10,
"cursor": "NTcjajQzQTRmcmUzMiFqZGY="
}
If you specify parameters for both types of iteration in one request (pagination via pagenumber and pagination via cursor) then pagination for cursor will take precedence over pagenumber.
Updated 22 days ago