Shopify Product API for Developers a Comprehensive Guide

Shopify Product API for developers

Introduction

If you're a Shopify store owner or developer looking to enhance your store’s functionality, understanding the Shopify Product API is crucial for developers. Whether you're adding new products, updating existing ones, or managing variants, the Shopify Product API allows you to do it all programmatically. In this guide, we'll explore the Shopify Product API for Developers, a complete guide to managing your product catalog with ease, from authentication to practical implementation.

Let’s dive into the key features of this powerful tool and show you how to use it to streamline your store’s operations.

If you're looking to further customize your store, consider checking out our Shopify Custom Theme Development Services.

What is the Shopify Product API?

The Shopify Product API is used to manage the product catalog using custom coding. By using the Shopify Product API, you can:

  • Add new products to your Shopify Store.
  • Update/Edit product details such as title, description, price, images, and variants.
  • View the product in the form of a list or an array.
  • Delete Products from the store.
  • Manage Product Variants and Inventory

 

Accessing the Shopify Product API

To use the Shopify API first, you have to do the authentication. There are 2 ways to do authentication listed below.

1. Custom Apps using Access Token

  • Develop a custom app inside your Shopify admin.
  • Add the necessary permissions for Product and Inventory APIs.
  • Copy the Admin/Storefront API access token, which you’ll use in your API requests.

2. Public Apps OAuth 2.0

  • Setting up OAuth is mandatory if your store is live 
  • During the OAuth flow, request the required API scopes to gain access.

Example Endpoint

  
    https://{store-name}.myshopify.com/admin/api/{version}/products.json
  

When making API calls, update the URL by replacing:

  • Store-name with your store’s Shopify subdomain (for example, myshop.myshopify.com).
  • Version with the desired API version, such as 2025-01.

This ensures you’re using the correct store and API version in your requests.

Once you’re familiar with authentication, you can move forward with tasks like Shopify Website Maintenance Services for seamless store operations.

Shopify Product API Endpoints

There are different endpoints for the Shopify Product API for Developers. Some of these are listed below.

1. Get All Products

  
    GET /admin/api/2025-01/products.json
  

Example URL:

  
    curl -X GET "https://{store-name}.myshopify.com/admin/api/2025-01/products.json" \
  -H "X-Shopify-Access-Token: {access_token}"
  


2. Get a Single Product

  
    GET /admin/api/2025-01/products/{product_id}.json
  

3. Create a New Product

  
    POST /admin/api/2025-01/products.json
    {
      "product": {
        "title": "Custom T-Shirt",
        "body_html": "Premium cotton",
        "vendor": "Your Brand",
        "product_type": "Apparel",
        "variants": [
          {
            "option1": "Small",
            "price": "19.99",
            "sku": "TSHIRT-SM"
          }
        ]
      }
    }
  

4. Update a Product

  
    PUT /admin/api/2025-01/products/{product_id}.json
    {
      "product": {
        "id": 123456789,
        "title": "Updated T-Shirt Title"
      }
    }
  

5. Delete a Product

  
    DELETE /admin/api/2025-01/products/{product_id}.json
  

6. Working with Variants

Variants are managed through the Product Variant API.

  
    GET /admin/api/2025-01/products/{product_id}/variants.json
  


REST vs GraphQL for Products

Shopify supports two types of API endpoints:

  • REST API: It is an easier and beginner-friendly way to get data.
  • GraphQL API: It is the most advanced and flexible way to get data using an API. You can request the data exactly as you want, no need to fetch all the data and then extract the required one.

Example GraphQL query:

  
    {
      products(first: 5) {
        edges {
          node {
            id
            title
            variants(first: 2) {
              edges {
                node {
                  id
                  price
                }
              }
            }
          }
        }
      }
    }
  


Common Use Cases for Product API

Shopify Product API is used for adding new things that Shopify does not support by default. Some common use cases are given below, where you can use the Shopify Product API:

  • Add Product Reviews to your Store.
  • Add Discounts based on custom conditions.
  • Allow Product Personalization so that customers can customize their products in real time to see how it will look.
  • Sync your Shopify Products with different platforms like Amazon, Etsy, and eBay.


Practical Example Shopify Product API Workflow

In this example, we'll show you a practical example of using the Shopify Product API using the Storefront API Access token. Follow these steps to practically add the Shopify Product API.

Step 1: Navigate to the Shopify Admin > Settings.

Shopify Product API for Developers - Complete Guide

Step 2: Scroll down to the Apps and sales channels tab and click on the Develop apps.

Shopify Product API for Developers - Complete Guide

Step 3: Click on the Create an app button.

Shopify Product API for Developers - Complete Guide

Step 4: Add the name of the app and click on the Create app button.

Shopify Product API for Developers - Complete Guide

Step 5: Select the Storefront API Scopes.

Shopify Product API for Developers - Complete Guide

Step 6: Select the Product Permissions and click the Save button.

Shopify Product API for Developers - Complete Guide

Step 7: Install the app in your Shopify store. 

Shopify Product API for Developers - Complete Guide

Step 8: Copy the access token and save it somewhere for future use.

Shopify Product API for Developers - Complete Guide

Step 9: Navigate to Oline Store > Themes > Edit code.

Shopify Product API for Developers - Complete Guide

Step 10: Navigate to the main-product.liquid file or theme.liquid file.

Shopify Product API for Developers - Complete Guide

Step 11: Add this code to your file.

  
    <script>
      const shopDomain = "test-shop-schema-markup.myshopify.com";
      const apiVersion = "2025-01";
      const storefrontToken = "849b82640e1c045341181c1134002527";

      const endpoint = `https://${shopDomain}/api/${apiVersion}/graphql.json`;

      async function getProducts() {
        const query = `
          {
            products(first: 5) {
              edges {
                node {
                  id
                  title
                  handle
                  description
                  variants(first: 2) {
                    edges {
                      node {
                        id
                        title
                        price {
                          amount
                          currencyCode
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        `;

        const response = await fetch(endpoint, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "X-Shopify-Storefront-Access-Token": storefrontToken
          },
          body: JSON.stringify({ query })
        });

        const data = await response.json();
        console.log("Products:", data.data.products.edges);
      }

      getProducts();
    </script>
  

Step 12: Save the changes.

Step 13: Press CTRL + Shift + I or right-click and click Inspect elements.

Shopify Product API for Developers - Complete Guide

Step 14: You will see the products array like this.

Shopify Product API for Developers - Complete Guide

Conclusion


In conclusion, the Shopify Product API is a game-changer for store owners and developers looking to customize and automate their store’s product management. By using this API, you can add, edit, and delete products, manage variants, and even integrate Shopify products with external platforms. Whether you choose the REST API for simplicity or the GraphQL API for more control, this tool can help you streamline workflows and unlock new possibilities for your store.  

For more insights into optimizing your Shopify store, don't forget to check out our Shopify eCommerce SEO Audit Service.

Frequently Asked Questions

The Shopify Product API allows developers to manage the product catalog of a Shopify store. It helps add, update, and delete products programmatically and provides full control over product variants, pricing, and inventory.

To authenticate the Shopify Product API, you can use either a custom app with an access token or a public app via OAuth 2.0. The access token or OAuth flow ensures that your API requests are authorized.

You can add a new product by making a POST request to the /admin/api/{version}/products.json endpoint with the product details in the request body, such as title, description, price, and variants.

Yes, you can update product details such as title, description, price, and variants by sending a PUT request to the appropriate product endpoint using the product ID.

To delete a product, make a DELETE request to the /admin/api/{version}/products/{product_id}.json endpoint, providing the product ID that you want to delete from the store.

The Shopify REST API is easier for beginners and works well for basic data retrieval, while the GraphQL API is more flexible and allows you to fetch only the specific data you need, making it more efficient for complex queries.

Yes, you can manage product variants using the Product Variant API. This includes retrieving, updating, and deleting product variants as needed, such as adjusting prices or adding new sizes or colors.

Comments(0)
You don't have any comments yet

Are You Looking for a Shopify Expert?

We design, develop, optimize, and scale high-converting Shopify stores.

Get in touch
Let's Connect
Shopify Plus eCommerce Development Agency ecomx agency

Looking for a Trusted Ecommerce & Shopify Plus Agency?

We design, develop, optimize, and scale high converting Shopify Ecommerce stores that drive sales.

Get in Touch
Ecomx shopify plus agency about us page Yasin

Looking for a Shopify expert to handle a small task? Shopify Migration Experts Agency Ecomx shopify plus agency

Let’s talk about your project

Shopify Custom Theme Development Services Live Chat