Solved

Sorting pagination

Jiri_Hacmac
Shopify Expert
10 0 10

Hello,

 

I' looking for some documentation about the "order" parameter on the Admin API

In the example https://www.shopify.com/partners/blog/relative-pagination there is a "order" parameter mentioned.

 

https://shop-domain.myshopify.com/admin/api/2019-07/products.json?order=inventory_total+desc&limit=250

I didn't find this param in the Admin API reference. 

Is the order param also available for orders and others endpoints?

And what are the possible values?

moving primates GmbH • https://www.movingprimates.de
Accepted Solution (1)
gilg
Shopify Partner
31 6 6

This is an accepted solution.

Replies 4 (4)

hassain
Shopify Staff (Retired)
624 104 188

Hey @Jiri_Hacmac ,

 

This parameter is unsupported by Shopify, and as a result it may change or stop working at any time. Use at your own discretion

To learn more visit the Shopify Help Center or the Community Blog.

gilg
Shopify Partner
31 6 6

This is an accepted solution.

Pretty sure it's supported on the admin graphql api - https://help.shopify.com/en/api/graphql-admin-api/reference/object/productsortkeys

 

Order Sort Keys: https://help.shopify.com/en/api/graphql-admin-api/reference/object/ordersortkeys

Customer Sort Keys: https://help.shopify.com/en/api/graphql-admin-api/reference/object/customersortkeys

I make Checkout Promotions on the app store. Native pre & post purchase upsells - used by over 1,800 merchants.
Jiri_Hacmac
Shopify Expert
10 0 10

Hey @hassain 

can you please verify it that it is not supported for REST admin API?
Does it mean, I have to use Qraphql to get sorted results?

 

What is the default sort order for GET/admin/api/2019-10/orders.json ?

 

 

moving primates GmbH • https://www.movingprimates.de
hassain
Shopify Staff (Retired)
624 104 188

Hi @Jiri_Hacmac 

 

Yes, I can confirm that using the GraphQL Admin API is the supported and ideal method of getting sorted results from Shopify.

 

From my knowledge, the default sort order of the orders.json REST endpoint is the "id" field in ascending order. The "id" is generated incrementally every time an order occurs on Shopify, so you can also intepret this sort order and ordered by the "created_at" date time in ascending order (i.e. older order first).

 

To learn more visit the Shopify Help Center or the Community Blog.