Reputation: 592
The Shopify API allows clients to download lists (products, collections, etc) with 250 items at a time. Is there a way to also upload new lists with multiple items with one API call as well? It looks like, from the documentation at api.shopify.com, that only one item can be created per call. If true, would be both counterproductive and extremely inefficient for users trying to interface the storefront with an existing inventory management system, for example.
Let's say we have a store with 20,000 products and 200 custom collections where, for the sake of argument, a product belongs to only one collection. Downloading information about the products would take 80 calls to products.xml, 1 call to custom_collections.xml, and 80 calls to collects.xml. We would need only 161 calls to the API to perform the operation, and that number is well under the limit of 500 calls in 5 minutes imposed by Shopify.
However, to perform the opposite task (create or modify the same number of products, one at a time, according to the documentation) would require 20,000 API calls to products.xml, 200 calls to custom_collections.xml and 20,000 calls to collects.xml, which would take 7 hours to complete at 500 calls every 5 minutes.
Is there a better way to do this?
EDIT I understand from the answers below that, indeed, the Shopify API does not allow creating/updating multiple products at a time. This is, in my opinion, a significant shortcoming in an otherwise efficient product, so I leave here my request for the implemention of this feature. For now I will have to create a service app that will be hitting the API non-stop, updating products as fast as possible.
Upvotes: 5
Views: 4384
Reputation: 11427
As of October 2019, the Shopify GraphQL API does have a bulk operations mutation, allowing for a large amount of work to get done. Probably not great for this use-case, but still, an improvement.
You do indeed need to make 20,000 API calls to create 20,000 products using the API. API calls are rationed out, 500 per 300 seconds. You are correct on all points.
A simple script will ensure you respect the API limits, so just start it, and if it takes seven hours to complete, so what? You are not charged $ per API call. You could also avoid the API issue altogether and just upload all 20,000 products directly into the shop with Shopify using a CSV file. No API calls are burned there.
Upvotes: 2
Reputation: 2872
No, there’s no way to batch-create products through the API.
When working with an inventory management system, I recommend:
since_id
per this article that talks about syncing with storesIf you still need more breathing room, contact [email protected] for a higher API limit, stating why you need it and how many more calls you need.
Edward, Shopify Developer Advocate
Upvotes: 1