Getting started overview

To begin developing with Shopify, the initial steps focus on establishing a development environment and acquiring the necessary credentials to interact with its APIs. Shopify provides two primary API options: the Admin REST API for managing store data and operations, and the Storefront API for accessing customer-facing data. Additionally, a GraphQL Admin API is available for more flexible data querying.

The standard workflow for new developers includes:

  1. Creating a Shopify Partner account: This account is distinct from a merchant account and is used for building apps, themes, or development stores for clients.
  2. Setting up a development store: A free, fully functional Shopify store for testing and development without affecting a live merchant store or incurring costs.
  3. Generating API credentials: Obtaining an API key and secret, or an access token, to authenticate requests to Shopify's APIs.
  4. Making a first API call: Executing a simple request to confirm successful authentication and connectivity.

Shopify's API uses OAuth 2.0 for authorization, allowing applications to request granular permissions to access and modify store data on behalf of a merchant. This approach enhances security by preventing applications from directly handling sensitive merchant credentials.

Create an account and get keys

Before making any API calls, you need to set up a development environment. This involves creating a Shopify Partner account and a development store.

Step 1: Create a Shopify Partner account

A Shopify Partner account is required for developers, agencies, and freelancers who build apps or themes, or set up stores for merchants. This account provides access to tools and resources specifically designed for the Shopify ecosystem.

  • Navigate to the Shopify Partner program signup page.
  • Follow the prompts to create your account. This typically involves providing an email address, setting a password, and agreeing to the Partner Program Agreement.
  • Once registered, you will have access to the Partner Dashboard, your central hub for managing development stores, apps, and client projects.

Step 2: Create a development store

Development stores are free, fully functional Shopify stores that can be used for building and testing themes and apps. They are not subject to a trial period and remain open as long as they are associated with a Partner account.

  • From your Shopify Partner Dashboard, select Stores from the left navigation menu.
  • Click Add store and choose Create a development store.
  • Provide a store name (this will form the .myshopify.com domain) and select an appropriate build purpose (e.g., "Create a new app" or "Test a theme or custom app").
  • Click Create development store. Shopify will provision your new store, which typically takes a few moments.

Step 3: Generate API credentials for an app

To interact with the Shopify API, you'll need to create a custom app within your development store to obtain API credentials. These credentials include an API key, API secret key, and an access token.

  • From your Shopify Partner Dashboard, navigate to Apps.
  • Click Create app and select Build a custom app.
  • Give your app a name (e.g., "My First API Integration") and select the development store you just created. Click Create app.
  • Once the app is created, you will be directed to its overview page. Go to the API credentials section.
  • In the Admin API access scopes section, click Configure Admin API scopes. Select the minimum necessary permissions for your first request. For example, to read product data, you would select read_products. Save your changes.
  • After configuring scopes, click Install app. This action generates the Admin API access token. Copy this token immediately as it will only be shown once. This is your primary credential for authenticated API requests.
  • Note down the API key and API secret key from the "API credentials" section if you plan to use OAuth flows or specific SDKs that require them.

Your first request

With your development store set up and API credentials obtained, you can now make your first authenticated API request. We will demonstrate using the Admin REST API to fetch a list of products. This example uses curl, a common command-line tool for making HTTP requests.

Prerequisites:

  • Your Admin API access token (obtained in Step 3).
  • Your development store's URL (e.g., your-store-name.myshopify.com).

Retrieve products using the Admin REST API

The Admin REST API allows you to manage various aspects of a Shopify store, including products, orders, customers, and more. To fetch products, you'll use the /admin/api/latest/products.json endpoint.

curl -X GET \
  "https://{your-store-name}.myshopify.com/admin/api/2024-07/products.json" \
  -H "X-Shopify-Access-Token: {your-admin-api-access-token}" \
  -H "Content-Type: application/json"

Replace {your-store-name} with your actual development store's subdomain and {your-admin-api-access-token} with the access token you generated. Note that Shopify APIs are versioned; the example uses 2024-07, but you should always refer to the latest supported API version in the documentation.

Expected response

If successful, the API will return a JSON object containing an array of products:

{
  "products": [
    {
      "id": 632910392, 
      "title": "Aerodynamic Copper Plate",
      "body_html": "<strong>Good product</strong>",
      "vendor": "Giant Bicycle",
      // ... other product details
    },
    // ... more products if available
  ]
}

If your development store does not have any products yet, the products array will be empty. You can add a test product through the store's admin interface (Products > Add product) or programmatically via the API to see data returned.

Quick Reference: Getting Started Steps

Step What to do Where to do it
1. Create Partner Account Register for a developer account. Shopify Partner program signup
2. Create Development Store Set up a free test store. Partner Dashboard > Stores > Add store
3. Create Custom App Register a new app to get API keys. Partner Dashboard > Apps > Create app
4. Configure API Scopes Set permissions (e.g., read_products). App settings > API credentials > Admin API access scopes
5. Get Access Token Install the custom app to generate token. App settings > API credentials
6. Make First Request Use curl or an HTTP client to fetch data. Your terminal/code editor (using your store URL and token)

Common next steps

After successfully making your first API call, you can explore various functionalities and development paths:

  • Explore more API endpoints: Review the Shopify Admin REST API reference to understand how to manage other resources like orders, customers, and inventory.
  • Use an SDK: Shopify offers official and community-maintained SDKs for various languages (e.g., Node.js, Ruby, Python, PHP). These SDKs abstract away much of the HTTP request boilerplate, simplifying development. For example, the Shopify Node.js API library simplifies API interactions and webhook management.
  • Develop a public app: If you plan to build an app for multiple merchants, you'll transition from a custom app to a public app. Public apps involve a more complex OAuth flow and require app listing approval on the Shopify App Store. The Shopify app development guide provides comprehensive details.
  • Build a theme: Enhance store aesthetics and functionality using Shopify's Liquid templating language and theme development tools. The Shopify theme development documentation is a starting point.
  • Implement webhooks: Subscribe to real-time events (e.g., new order, product update) using webhooks. This allows your application to react to changes in a Shopify store without constant polling. Learn more about Admin API webhooks.
  • Learn about Shopify's GraphQL API: For more efficient data fetching and complex queries, consider using the Admin GraphQL API especially for fetching specific fields or related resources.
  • Explore storefront development: If you're building a custom frontend, dive into the Storefront API and custom storefronts to create headless commerce experiences.
  • Security practices: Familiarize yourself with Shopify's security best practices for app development, especially regarding API key management and securing payloads.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting tips:

  • 401 Unauthorized: Invalid API Key or Token:
    • Verify your access token: Ensure the X-Shopify-Access-Token header contains the correct, full access token. Remember that custom app tokens are shown only once upon installation.
    • Check API Key/Secret: If using OAuth, verify your API Key and Secret are correct.
    • Ensure app is installed: The custom app must be installed on your development store to generate an access token.
  • 403 Forbidden: Insufficient Permissions:
    • Review API scopes: Double-check that your custom app has the necessary Admin API access scopes enabled for the endpoint you are trying to reach (e.g., read_products for fetching products). You might need to uninstall and reinstall the app to apply new scope changes.
    • Correct API version: Ensure the API version in your URL (e.g., 2024-07) is supported and matches your expectations.
  • 404 Not Found: Incorrect Endpoint or Store URL:
    • Verify the store URL: Ensure {your-store-name}.myshopify.com is correctly typed.
    • Check the endpoint path: Compare your API endpoint path (e.g., /admin/api/{version}/products.json) against the official Admin REST API documentation.
  • CORS errors in browser:
    • Shopify's Admin API is generally not designed for direct browser-side calls due to Cross-Origin Resource Sharing (CORS) restrictions. Use a backend server or a tool like curl or Postman for API interactions.
  • Rate Limiting (429 Too Many Requests):
    • If you make too many requests in a short period, Shopify's API might return a 429 status. Refer to the Shopify API rate limit documentation to understand current limits and how to handle them. Implement exponential backoff in your code.
  • JSON parsing errors:
    • Ensure your request includes the Content-Type: application/json header if you are sending a request body, and that your JSON payload is valid.