How can I update inventory quantity via API?

Topic summary

Goal: change a product’s inventory quantity via API using the Shopify Python SDK.

Key guidance provided:

  • Use the Shopify Admin API inventory resources (docs linked). Inventory is tracked on InventoryItem and InventoryLevel, tied to a Location per product variant.
  • Workflow suggested: after creating/saving the product and variants, get variant.inventory_item_id and call InventoryLevel.set with inventory_item_id and location_id to set the quantity for that location. The responder wasn’t certain about Python SDK specifics but pointed to the REST docs and examples.

Notable clarifications:

  • “Location” refers to the fulfillment/stock location; understanding this enabled the original poster to manage inventory successfully.

Code context:

  • A Python snippet showed product creation; the inventory snippet was partial. The linked docs are central for implementation details.

Current status:

  • The original poster confirmed they solved it but did not share code.
  • Follow-up questions asking how they achieved it, whether any libraries are required, and where to write the code remain unanswered. The thread is partially unresolved.
Summarized with AI on January 10. AI used: gpt-5.

I would like to change inventory quantity of products, but I don’t even know how to do that.

Here is a part of example to list a product I try to do.

product = shopify.Product()
product.title = "example"
product.save()

The SDK should be similar to Shopify Admin API, so check the API docs on inventory handling:

https://shopify.dev/api/admin/rest/reference/inventory

https://shopify.dev/api/examples/product-inventory

Inventory is now tracked against InventoryItem and InventoryLevel in connection to a Location on each product variant.

I’m not familiar with the Python SDK, not sure if InventoryItem will be auto-populated on the Variant object, but I’m guessing after saving the product, you can do something like:

inv = shopify.InventoryLevel()
inv.set(inventory_item_id=variant.inventory_item_id, location_id=

Should return a collection, then call set() method to set the inventory for a location.
1 Like

Thank you for your help

I didn’t even understand what location was.

I could manage inventory.

I appreciate it again!

Hi, can you please tell me how did you acheive this via api?

hi, should i install any libraries for acheiving that and also can you please tell me where should i write this code