A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi, I've shopify e-commerce. I want to create a page that displays products with sorting options. I want to sort by title, price, vendor, most frequently bought. So the options will looks like this :
I get data from the graphql API : "/admin/api/2021-04/graphql.json"
So, what I'm asking is how to sort by price ? I've try to make request to graphql API like this :
as you can see that I got an error
As you can see, I also use the same API version (2021-04)
How come the API is different with the documentation ???
And then my second question is, how can I sort product by "Most Frequently Bought" ?
I think that is standard features of e-commerce.
Thank you very much !
Hey @ricky7171,
The endpoint URL you're calling is for the admin API, but the documentation you linked is from the storefront API.
The admin API is used by apps that wish to extend functionality, and is usually used by apps or sales channels that will be embedded in the Shopify admin.
The storefront API is used for creating a custom storefront or purchase experience for an individual store.
If you meant to call the storefront API, make sure the URL is in the format of: myshopify.com/api/2021-04/graphql.json
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi, thank you for your reply. Ok, if I use storefront API, can I sort product by price ?
The most important thing here is where I can call an API that can sort products by price
I mean not using liquid (because if I sort by price using liquid, it only applies to 1 page (cannot paginate). And actually it doesn't need to use liquid, I can use javascript myself if only 1 page)
Thank you