How to paginate the products?

Solved
DaviAmaral
Excursionist
16 2 1

How to do that?

 

When I am trying to do that not all the products are showing. 

 

When I do the: 

/admin/api/2019-07/products/count.json

 

I am receiving this message: 

{"count":258}

 When I try to the pagination: 

/admin/api/2019-07/products.json?limit=250&page=1

 

I am receiving this message: 

{"errors":{"page":"page cannot be passed. See https:\/\/help.shopify.com\/api\/guides\/paginated-rest-results for more information."}}

 

0 Likes
Busfox
Shopify Staff
Shopify Staff
619 48 94

Hi @DaviAmaral,

 

Did you view the url in the error message? It should show how to use cursors to paginate through products. Essentially, you need to look for the link header, which will contain a link for the next page and the previous page. You would fetch the next page by making a request to that url.

 

Cheers,

0 Likes
DaviAmaral
Excursionist
16 2 1

Yes, I forgot to put the second part of the question:

 

https://{shop}.myshopify.com/admin/api/2019-07/products.json?page_info={page_info}&limit=250

 

Really don't understand what {page_info} means.

 

"A unique ID used to access a certain page of results. The page_info parameter can't be modified and must be used exactly as it appears in the link header URL."

 

How can I get this unique ID.

0 Likes
Busfox
Shopify Staff
Shopify Staff
619 48 94

Hi @DaviAmaral,

 

The page_info is provided in the link header value. Essentially, we give you the url to make a GET request at to receive the next page of results. You don't need to provide any additional parameters.

0 Likes
DaviAmaral
Excursionist
16 2 1

This is an accepted solution.

I created a solution for doing this:

.../products.json?direction=next&last_id=8151827848&limit=250&order=id

where 8151827848 was the last product in my previous consult.

I don't know if we ware talking about. 

I hope it is helpful.   

 

Tks guys! 

0 Likes
ITAgnesmeyer
New Member
2 0 0

what a bad solution.
There is a pagination, but it cannot be used.
So if I want to use the built-in pagination, I have to search an HTML tag in the header for a page_info entry.
Unfortunately, this page_info only shows the current page.
The solution with the last number has the disadvantage that it cannot be used with since_id.
This means you cannot paginate if you use since_id.

 

 

0 Likes
DaviAmaral
Excursionist
16 2 1

Just to be clear, I don't work In Shopify, I am just a User like you trying to help others users.

And trying to help you, try that:

...admin/api/2019-10/products.json?direction=next&last_id=81732365528173236552&last_value=3672573149263&limit=50&order=id

 

To figure out that, you can look at how works the pagination in the Shopify admin.

 

 

 

 

 

 

0 Likes
ITAgnesmeyer
New Member
2 0 0

I also didn't want to make your approach bad.

But the developers at Shopify only acted a little impractical.

Pagination should make life easier for API users and not more difficult :(

Thanks again for your approach.

With your approach you can of course work.

 

 

0 Likes
KillerBee3453
New Member
2 0 1

 Is "Direction" a valid query parameter and if so where did you find it at? I look through the API and I don't see any of this things listed there 

jw_pei
New Member
6 0 0

jw_pei_0-1613716186369.png

 

0 Likes