Shopify API - Retrieve all variants for a product using Postman

Shopify API – Retrieve All Variants For A Product Using Postman

The term “variant” refers to a new version of a product. For example, color or size, if you do not create a new variation, shirts in three colors (yellow, blue, and green) will be treated as three separate goods. You can think of yellow, blue, and green shirts as three different types of the same shirt by using Product Variations.

Each product can have up to 100 variations. At Shopify, almost every business creates new variants of a product, you can read Shopify API: Create A New Product Variant to know more about creating product variants. After creating, the owner sometimes needs to get all variants for a product to make adjustments. This is the reason today I’m going to show you how to retrieve all variants for a product using Postman in Shopify API. 

Remember with Postman in Shopify API, results will be returned default 50 variants per page.

Now let’s explore the article!

If this is the first time you make a call in the Postman, you must generate API credentials from the Shopify admin

Generate API Credentials From Shopify Admin

Follow the process in How to build a custom app for Shopify in 2022? to know how to access Shopify API. 

  • After creating an app, you need to assign “Products” scopes to the admin API scopes. 
  • Besides, remember the Admin API access token and the API key to retrieve all variants for a product in the Postman. 

Before retrieving all the variants for a product, we need to determine the product_id of those variants. Because the command requires all variants for a product that contains product_id.

  • From the Admin dashboard, choose products.
  • Then search for the product that you want to retrieve variants of its. 
  • Ultimately, copy the product_id in the URL. 

Example: The product_id of Beehexa Quickbooks – Shopify T-Shirt 2021 product = 4958434295871

Now, we are ready to retrieve all variants for a product.

Retrieves all variants for a product using Postman

  • First, log in to your Postman and create a new workspace
  • Then create a new GET with this URL:
https://{API_key}:{admin_API_access_token}@{shop}.myshopify.com/admin/api/{api-version}/{resource}
Code language: JavaScript (javascript)
  1. {API_key} – The API key that you generated.
  2. {admin_API_access_token} – The admin API access token that you generated.
  3. {shop} – The name of your development store.
  4. {api-version} – The supported API version that you want to use.
  5. {resource} – A resource endpoint from the REST Admin API.

Or you can copy this example, remember change {resource} to {products/product_id/variants}:

https://ed86d512a2c95387ffa25f67074a222b:[email protected]/admin/api/2021-10/products/4958434295871/variants.json
Code language: JavaScript (javascript)
  • After that, paste the URL above.
retrieve all variants for a product

Then clicks on send

Response: The API will return all variants of a product. 

{ "variants": [ { "id": 33375530221631, "product_id": 4958434295871, "title": "Default Title", "price": "100000.00", "sku": "BT002", "position": 1, "inventory_policy": "deny", "compare_at_price": null, "fulfillment_service": "manual", "inventory_management": "shopify", "option1": "Default Title", "option2": null, "option3": null, "created_at": "2021-02-19T16:59:14+09:00", "updated_at": "2021-02-19T16:59:50+09:00", "taxable": true, "barcode": null, "grams": 0, "image_id": null, "weight": 0.0, "weight_unit": "kg", "inventory_item_id": 35539582746687, "inventory_quantity": 100, "old_inventory_quantity": 100, "requires_shipping": true, "admin_graphql_api_id": "gid://shopify/ProductVariant/33375530221631" }, { "id": 39627489050687, "product_id": 4958434295871, "title": "Yellow", "price": "1.00", "sku": "", "position": 2, "inventory_policy": "deny", "compare_at_price": null, "fulfillment_service": "manual", "inventory_management": "shopify", "option1": "Yellow", "option2": null, "option3": null, "created_at": "2022-03-17T17:37:48+09:00", "updated_at": "2022-03-17T17:37:48+09:00", "taxable": true, "barcode": null, "grams": 0, "image_id": null, "weight": 0.0, "weight_unit": "kg", "inventory_item_id": 41722938818623, "inventory_quantity": 0, "old_inventory_quantity": 0, "requires_shipping": true, "admin_graphql_api_id": "gid://shopify/ProductVariant/39627489050687" }, { "id": 39627489148991, "product_id": 4958434295871, "title": "Red", "price": "1.00", "sku": "", "position": 3, "inventory_policy": "deny", "compare_at_price": null, "fulfillment_service": "manual", "inventory_management": "shopify", "option1": "Red", "option2": null, "option3": null, "created_at": "2022-03-17T17:38:09+09:00", "updated_at": "2022-03-17T17:38:09+09:00", "taxable": true, "barcode": null, "grams": 0, "image_id": null, "weight": 0.0, "weight_unit": "kg", "inventory_item_id": 41722938916927, "inventory_quantity": 0, "old_inventory_quantity": 0, "requires_shipping": true, "admin_graphql_api_id": "gid://shopify/ProductVariant/39627489148991" } ] }
Code language: JSON / JSON with Comments (json)
response_retrieve all variants for a product

The above are all steps to retrieve all variants for a product using Postman with Shopify API. If you have any questions, please leave a comment below or refer to our Shopify api documentation.

If you still do not understand the tutorial’s content, you can watch the video below for a more overview.

Shopify API – Retrieve all variants for a product

Hopefully, you can do it!

Shopify API - Retrieve all variants for a product using Postman

Shopify API – Retrieve All Variants For A Product Using Postman

Join The Ride

Subscribe to our fortnightly newsletter with stories from our latest adventures and the best travel tips

Table of Contents