Development discussions around Shopify APIs
I currently store references to SKUs in my own db so I can track my inventory across multiple sales channels, Shopify included.
When I want to update inventory via the Shopify JSON API, I have to pass in a Shopify product ID (rather than my SKU value).
Consequently, I can't seem to find a way to search for a product by its variants' SKU value, and update the stock accordingly. This is supported everywhere else in eBay/ Magento/ Amazon and so forth; Is this functionality supported in the Shopify API (bearing in mind I can search from the product screen by SKU), and what does the API call look like?
Thanks, Ian.
In Shopify skus aren't forced to be unique so searching for a single product based on sku wouldn't work in the same way it would at the other providers.
That being said, it appears that the search API that is used by the admin is open and you can leverage that to find the products you are looking for:
curl -H "Content-Type: application/json" \ https://user:pass@yourshop.myshopify.com/admin/products/search.json?query=sku:abracadabra
Chris | 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
I tried as below but it gives 404.
Is there any mistake? The same URL works on the browser after logged in site.
curl -H "Content-Type: application/json" https://apikey:password@mysite.myshopify.com/admin/api/2020-07/variants/search.json?query=sku:XYZ
Appreciate the response Chris, will check it out. I think it's a bit strange that this isn't inherently supported in the API as it would make sense for a lot of sellers, and returning a list of matched variants would be fine. I think it's down to the seller to make a good choice in SKU naming rather than the marketplace, so not enforcing 'uniqueness' makes sense to me anyway.
That works nicely, thanks. Also tried it with the OAuth token which also works fine.
Thanks for your help!
This is not working against the PUT request. It shows error "{'errors': {'id': 'expected String to be a id'}}". Could you help me with this.
Hi there was a question like this the other day.
You can do this with graphql.
Example below:
https://community.shopify.com/c/Shopify-APIs-SDKs/sku-search-return-not-found/m-p/793300#M52069
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023