FROM CACHE - en_header

REST API: Create New Product with Variants and Variant Images in One API Call

Solved
ReneK
Tourist
10 0 2

Is it possible to upload Product with Images and assign those images to Variants in just one REST API request, please?

 

At this moment, the fastest way we know is this:

  1. Create new product with multiple variants and multiple images using (here, images will not be assigned to variants): 
    POST /admin/api/2021-07/products.json
  2. After processing the above, we get a Variant IDs and Image IDs. We assign Image IDs to Variant IDs using another REST API call:
    PUT /admin/api/2021-07/products/632910392/images/850703190.json

 

We have several thousand of products on Shopify. Because of Shopify API Rate limits ( https://shopify.dev/api/usage/rate-limits ), we can have two REST API calls / second.  Accomplishing the above in only one call, would help us reduce processing time by 50%, which would be significant.  

 

Thank you.

 

 

 

 

Accepted Solution (1)

Accepted Solutions
PaulNewton
Shopify Partner
4219 304 902

This is an accepted solution.

For REST with existing variants

 Each product_image should have a variants_ids 

https://community.shopify.com/c/Shopify-APIs-and-SDKs/Product-Variant-Image-and-Option-Update-via-AP... 

Otherwise look into doing this with GraphQL as REST is inherently not designed for a situation of creation>creation>creation<reference<reference<reference.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com

View solution in original post

Replies 3 (3)
PaulNewton
Shopify Partner
4219 304 902

This is an accepted solution.

For REST with existing variants

 Each product_image should have a variants_ids 

https://community.shopify.com/c/Shopify-APIs-and-SDKs/Product-Variant-Image-and-Option-Update-via-AP... 

Otherwise look into doing this with GraphQL as REST is inherently not designed for a situation of creation>creation>creation<reference<reference<reference.

Finally Combinable Discounts - EARLY ACCESS ONLY - Use Free Shipping With Other Discounts

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org
Problem Solved? ✔Accept and Like solutions to help future merchants
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
ReneK
Tourist
10 0 2

Thank you Paul. I will check GraphQL. I am closing this question now.

markus12
Shopify Partner
12 1 2