Back

Shopify API Essential Guide

Jul 17, 20246 minute read

What type of API does Shopify provide?

Shopify provides two main types of APIs:

REST API

  • Shopify offers a REST Admin API for building apps and integrations.
  • The REST API covers data on products, customers, orders, inventory, fulfillment, and more.

GraphQL API

  • Shopify provides a GraphQL Admin API.
  • The GraphQL API allows developers to query specific data in a single request.

Additional APIs

  • Storefront API for custom storefronts
  • Ajax API for dynamic elements in Shopify online stores
  • Shopify Functions APIs for customizing backend logic

Shopify's provision of both REST and GraphQL APIs gives developers flexibility in choosing the most suitable approach for their specific use case.

Does the Shopify API have webhooks?

Yes, the official Shopify API does have webhooks. Here are the key points about Shopify webhooks:

Webhook Support

  • Shopify provides webhook functionality as part of its API to allow apps to receive near real-time notifications about events that occur in a shop.

  • Webhooks are useful for keeping your app in sync with Shopify data or triggering actions after specific events occur.

Types of Events

You can subscribe to many different types of webhook events, including:

  • Order events (e.g. orders/create, orders/paid, orders/fulfilled)
  • Product events (e.g. products/create, products/update, products/delete)
  • Customer events (e.g. customers/create, customers/update)
  • Inventory events
  • Refund events
  • And many more

Key Concepts

  • Webhook topics: Define the type of event your app receives notifications for (e.g. "products/create").

  • Webhook subscriptions: Declare your app's intention to receive webhooks for a specific topic.

  • Webhook payloads: The data sent to your app when an event occurs, containing details about the event.

Best Practices

  • Use webhooks instead of continuously polling the API for changes, as it's more efficient.

  • Implement proper verification of incoming webhooks using the HMAC header.

  • Handle potential duplicate webhook deliveries by checking the unique event ID.

Setting Up Webhooks

To set up webhooks, you typically:

  1. Register webhook subscriptions for your app, specifying the topics and endpoint.
  2. Implement an endpoint in your app to receive and process the webhook payloads.

Shopify provides libraries and tools to help manage webhooks in your app.

Rate Limits and other limitations

Here are the key points about Shopify API rate limits:

Rate Limits by Plan

  • Standard plan:

    • GraphQL Admin API: 50 points/second
    • REST Admin API: 2 requests/second
  • Advanced plan:

    • GraphQL Admin API: 100 points/second
    • REST Admin API: 4 requests/second
  • Shopify Plus:

    • GraphQL Admin API: 500 points/second
    • REST Admin API: 20 requests/second
  • Commerce Components by Shopify:

    • No rate limits

Rate Limiting Methods

  • Leaky bucket algorithm is used for all APIs
  • GraphQL Admin API uses calculated query cost
  • REST Admin API uses request-based limits
  • Storefront API has no rate limits

Key Considerations

  • Limits are per app and per store combination
  • Bucket size and leak rate determine burst behavior
  • Exceeding limits results in 429 Too Many Requests errors
  • Rate limits header shows current usage
  • Resource-based limits exist for certain endpoints
  • Checkout-level throttling applies to Storefront API

Best Practices

  • Use industry standard techniques for limiting calls
  • Cache results where possible
  • Implement request queues with exponential backoff
  • Design apps to be resilient to rate limiting
  • Monitor usage via rate limit headers

The rate limits were recently increased for Advanced and Plus plans to provide more capacity for apps and integrations. Developers should implement proper error handling and throttling in their apps to work within these limits.

Latest API Version

Based on the search results provided, here are the key points regarding the most recent version of the Shopify API:

  1. The most recent stable version of the Shopify API is 2024-07.

  2. Shopify releases a new API version every 3 months at the beginning of each quarter.

  3. The current release schedule for 2024 includes:

    • 2024-01 (released January 1, 2024)
    • 2024-04 (released April 1, 2024)
    • 2024-07 (released July 1, 2024)
    • 2024-10 (upcoming release candidate)
  4. Each stable version is supported for a minimum of one year from its release date.

  5. The 2024-10 version is currently a release candidate, which means it's the next upcoming version but not yet stable.

  6. Shopify strongly recommends updating apps to make requests to the latest stable API version every quarter.

  7. When specifying an API version in requests, you should use the format /admin/api/{api_version}/{endpoint}.json for REST APIs or /admin/api/{api_version}/graphql.json for GraphQL APIs.

It's important to note that while 2024-07 is the most recent stable version, developers should always strive to use the latest stable version and keep their apps updated to ensure they have access to the latest features and improvements.

How to get a Shopify developer account and API Keys?

Step 1: Sign up for a Shopify Partner account

  1. Visit the Shopify Partner Program website at https://www.shopify.com/partners.

  2. Click on "Join now" or "Become a Partner".

  3. Complete the signup process, providing information about your role and experience.

Step 2: Create a development store

  1. Once you have a Shopify Partner account, create a development store.

  2. If you created your Shopify Partner account after April 28, 2023, a quickstart development store is automatically created for you.

Step 3: Enable custom app development

  1. In your Shopify admin, go to Settings > Apps and sales channels.

  2. Click on "Allow custom app development".

Step 4: Create a custom app

  1. In your Shopify admin, go to Settings > Apps and sales channels.

  2. Click on "Create an app".

  3. Enter the App name and select an App developer.

Step 5: Set up API credentials

  1. Once your app is created, access the API credentials.

  2. You'll receive an API key and API secret key.

  3. Set the appropriate API scopes for your app based on the functionality you need.

What can you do with the Shopify API?

Here are the key data models you can interact with using the Shopify API, along with what is possible for each:

Products

  • Create, read, update and delete products
  • Manage product details like title, description, vendor, product type, etc.
  • Add/remove product images and media
  • Set product status (active, draft, archived)
  • Manage product SEO information
  • Associate products with collections

Variants

  • Create, read, update and delete product variants
  • Manage variant details like SKU, price, compare at price, inventory quantity, etc.
  • Set variant options (e.g. size, color)
  • Upload variant-specific images
  • Manage inventory for variants

Options

  • Add, update and remove product options (e.g. Size, Color)
  • Set option values (e.g. Small, Medium, Large for Size)
  • Link options to variants

Collections

  • Create, read, update and delete collections
  • Manage collection details like title, description, etc.
  • Set collection rules to automatically include products
  • Manually add/remove products from collections

Orders

  • Retrieve order information
  • Update order status
  • Add, modify or remove line items
  • Manage fulfillments and shipments
  • Process refunds and returns

Customers

  • Create, read, update and delete customer accounts
  • Manage customer details like name, email, addresses, etc.
  • View customer's order history
  • Add/remove customers to groups or segments

Inventory

  • Track inventory levels for products/variants
  • Adjust inventory quantities
  • Set inventory policies
  • Manage inventory across multiple locations

Metafields

  • Add custom metadata to various resources (products, orders, etc.)
  • Read, update and delete metafield data

Webhooks

  • Create webhook subscriptions for various events
  • Receive real-time notifications when events occur

This covers the main data models, but there are many other resources available through the API as well. The Shopify API provides extensive capabilities for interacting with and managing nearly all aspects of a Shopify store programmatically.