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. Using Product Variations, you can think of yellow, blue, and green shirts as three different types of the same shirt.
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 why 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 by default with 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 of 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.
Shopify Wix Integration
Shopify Brivity Integration
Shopify Apptivo Integration
Retrieve 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}
ย
-
- {API_key} โ The API key that you generated.
-
- {admin_API_access_token} โ The admin API access token that you generated.
-
- {shop} โ The name of your development store.
-
- {api-version} โ The supported API version that you want to use.
-
- {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
ย
-
- After that, paste the URL above.
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"
}
]
}
The above are all steps to retrieve all variants for a product using Postman with Shopify API. If you have any questions, please 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.
Hopefully, you can do it!