The SkyHub API provides the ability to paginate results obtained from orders and products queries. To do this, simply specify the range of records to be returned by the API using the parameters indicated below:
page: indicates the page number of records that will be returned. If not specified, the first page will be returned (default value 1);
per_page: indicates the number of records to return. In both features (products and orders), per_page has 100 as default and also as maximum value.
In the example below, SkyHub API returns products that are in the range of 101 to 200:
What happens if I request 100 records from page 100,000?
In this example we would have to go through 10,000,000 entries in our index to find the records of the requested page. The response time would be very high and the request would result in timeout.
To avoid this problem, the maximum number of entries we go through our index is 10,000 entries. For any request for a page that is beyond the first 10,000 entries, a bad request (HTTP status 400) error is returned.
The way to mitigate this limitation is to use filters (see the article "Filters" below).
We currently use cursor paging for the products' endpoint. Whenever a request is made in the product endpoint and the response of this request exceeds the quantity of 100 products, an option called "next", containing the URL of the next page of the query, will be available in the response footer.
This feature is not available for orders' endpoint
The SkyHub API provides the ability to filter query results from order and product endpoints by using query params:
In the example above, only products with "enabled" status will be returned.
Example in cURL:
curl --request GET \--url 'https://api.skyhub.com.br/products?status=enabled' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--header 'X-User-Email: email@example.com' \--header 'X-Api-Key: YOUR-API-KEY-HERE' \--header 'X-Accountmanager-Key: token_account'
The filtering available fileds are described in the documentation for each API method. Visit our API Explorer!