Filtering Product Variants without going through all products using AdminAPI

supspotify_spot
Shopify Partner
2 0 0

Hi! So, I tried using this on my browser: https://mystore.myshopify.com/admin/products/search.json?query=barcode:SMPLEBARCODE

It works on my browser, but when I try using it on my code, it give me a Status Code 404 NOT FOUND

I know I can filter product variants using a barcode or sku but I don't wanna go through all the products then filtering their variants until I find what I'm looking for. Say, when I have 500 or more products, it'll take a long time before I find the product variant that I want.
Can anyone help me with this?

Replies 5 (5)
Busfox
Shopify Staff (Retired)
Shopify Staff (Retired)
628 49 109

Hi there,

The Product API does not have a search endpoint. That's why you are receiving a 404.

To find a specific variant, you'll need to fetch every product and filter from there. Storing them on your end intially and fetching occasionally to keep the records up to date would be one way to make things speedier to grab what you need after the initial sync.

That being said, if you have 500 products, only two API calls would need to be made to receive all products. The response would include variant information, which you could do whatever you need to with. I'm not sure that would qualify as a long time.

Andrew | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

supspotify_spot
Shopify Partner
2 0 0

Hi! Just one more question, let's say I have about 500,000 products. Will this affect the response time when I make a call to get all products? Or it wouldn't really make any difference if I have 5 or 500,000 products?

Identixweb
Shopify Expert
34 0 2

Hello @supspotify spotify

Did you find any solution for variant filter in product api?

I have related issue same as you.

Best Regards,
Shopify Expert: https://experts.shopify.com/identixweb
Shopify App Partner: https://apps.shopify.com/partners/identixweb
Email: info@identixbweb.com
Skype: identixweb
Site: https://identixweb.com
Identixweb
Shopify Expert
34 0 2

I need something like this:

admin/products.json?fields=options[{"name" : "Size"}]

Best Regards,
Shopify Expert: https://experts.shopify.com/identixweb
Shopify App Partner: https://apps.shopify.com/partners/identixweb
Email: info@identixbweb.com
Skype: identixweb
Site: https://identixweb.com
mikemainguy
New Member
2 0 0

IDK if they're using ruby on the backend still, but this seems like a very useful feature (I need it also as I need to filter out a bunch of variants across many products for a particular social selling site that doesn't allow a particular variant of my product).