With pagination you retrieve a product feed in parts instead of all products in one response. Combine it with filters to only retrieve the products you need.
Please note: pagination only works with one campaign per request. If you combine records with multiple program_id[] values, you get a 400 error. Use a separate feed URL for each campaign.
When to Use Pagination
Always. Without the records parameter you get the complete product feed in one response, which can be hundreds of megabytes or more for large feeds. A single request stops after about 5 minutes, so a large feed without pagination ends up incomplete.
How to Use Pagination
- Add
&records=1000to the feed URL. You get the first 1000 products. - Read the
X-Next-Urlresponse header. It contains the full URL of the next page. - Request that URL to get the next 1000 products.
- Repeat until the response has no
X-Next-Urlheader. You then have all products.
Always use the X-Next-Url exactly as you receive it. It adds a search_after value that refers to the last product of the previous page, so you can't calculate it yourself. This also means your software must be able to read response headers. If it can't, use filters to keep the feed small.
Each response also contains:
- X-Current-Count: the number of products on this page. This is the value you requested, except on the last page.
- X-Total-Count: the total number of products in the feed. Use it to check that you received all products.
Pagination and the Rate Limit
Every page counts as a request for the rate limit of 30 requests per minute per IP address. Request pages one after another, never at the same time. If you get a 429 response, wait the number of seconds in the Retry-After header before you request the next page. Read more in Rules and guidelines for downloading and processing product feeds.
Example of a Feed URL with Pagination
This example requests a product feed with 50 products per page:
https://daisycon.io/datafeed/?media_id=22848&standard_id=1&language_code=fr&locale_id=3&type=xml&program_id=21835&records=50&encoding=utf8
Example of Response Headers
The response headers for the request above:
X-Total-Count: 80 X-Current-Count: 50 X-Next-Url: https://daisycon.io/datafeed/?media_id=22848&standard_id=1&language_code=fr&locale_id=3&type=xml&program_id=21835&records=50&encoding=utf8&search_after=%5B%229ddb817799f9e33217cc07a4d6ff295e%22%5D
This feed contains 80 products. The first request returns 50 products, the request to the X-Next-Url returns the remaining 30. That last response has no X-Next-Url header, so all products have been retrieved.