Pagination in requests to Yandex Market API for sellers
Some queries do not return the result in its entirety, but page by page. To get the full result, run several consecutive queries. — in each new request, pass a parameter with the next page of results.
Depending on which parameter needs to be passed, pagination can be of two types:
- with the page ID — parameter
page_token; - with the page number — parameter
page.
If both types of pagination are available in the method, use page ID (page_token), not her number.
Pagination with the page ID
Examples of methods:
- POST v2/businesses/{businessId}/offer-cards
- POST v2/campaigns/{campaignId}/offer-prices
- GET v2/campaigns/{campaignId}/returns
To get the full result:
-
Make a request where:
- Don't pass it on
page_token. - If desired, send
limit. Then this parameter will need to be passed in each subsequent request.
The response will return the parameter
paging. - Don't pass it on
-
If in
pagingthe parameter returnednextPageTokenso, there is the next page of the result. Repeat the request, where pass the valuenextPageTokenin the parameterpage_token.Parameter Value
nextPageTokenThis is not a page number, but a string that needs to be passed in the request.
If there is no parameter, then the last page is returned. Make more requests no need.
-
Keep executing requests until it returns
nextPageToken.
Some methods in the parameter paging They are returning prevPageToken
This is the ID of the previous results page.
To get the previous page, pass its ID in the parameter page_token. For the first page prevPageToken It doesn't come back.
Pagination with the page number
Some of the methods with this type of pagination are already outdated
The rest will be marked obsolete in the future.
Examples of methods:
To get the full result:
-
Make a request where:
- Don't pass it on
page. - If desired, send
pageSize. Then this parameter will need to be passed in each subsequent request.
The response will return the parameter
pagerwith the number of result pagespagesCount. - Don't pass it on
-
If in
pagesCountmore than one page returned, repeat the requests — in the parameterpagesend the page numbers (2,3and to the last one).