Getting started

The GraphQL Endpoint

Unlike the REST Admin API which has a variety of endpoints, the GraphQL Admin API has a single endpoint:

POST https://my-store-name.myshopify.com/admin/api/graphql.json

Make your first call to the GraphQL Admin API

We recommend installing Shopify’s own GraphiQL app to explore your shop’s data using the new API.

Once you've installed the app, you can test it by running the following query:

query {
  shop {
    name
    primaryDomain {
      url
      host
    }
  }
}

A successful query results in a response similar to the following:

{
  "data": {
    "shop": {
      "name": "graphql",
      "primaryDomain": {
        "url": "https://graphql.myshopify.com",
        "host": "graphql.myshopify.com"
      }
    }
  }
}

Congratulations, you’ve made your first call to the GraphQL Admin API!

Authentication

The GraphQL Admin API requires an access token for making authenticated requests.

Getting your access token

You can obtain an access token either by creating a private app and using that app's API key, or following the OAuth authorization process.

Private App To get the access token:

  1. From your Shopify admin, select Apps.
  2. Click Manage private apps.
  3. Click Create new private app.
  4. Fill out the details of your private app.
  5. Click Save.
  6. Use the newly generated Password as the access token.

OAuth To get the access token, follow the OAuth Authorization flow in the OAuth Guide.

Using your access token

This access token will need to be included as a “X-Shopify-Access-Token” header in all GraphQL. We’ll go over some concrete examples of using it in the next section.

Query the GraphQL Admin API

You can access the GraphQL Admin API endpoint using cURL or any other HTTP client. For the following examples, make sure to replace <SHOP> with your store’s domain and <ACCESS_TOKEN> with the token you generated in the Authentication section.

curl

To make a query to the using curl, send a POST request with your query as the JSON payload.

curl -X POST \
"https://<SHOP>.myshopify.com/admin/api/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Access-Token: <ACCESS_TOKEN>" \
-d '
{
  shop {
    products(first: 5) {
      edges {
        node {
          id
          handle
        }
      }
      pageInfo {
        hasNextPage
      }
    }
  }
}

Example Queries

In GraphQL, queries are the equivalent of REST’s GET action verb. They generally begin with one of the objects listed under QueryRoot and can get data from any connections that object has. Even though a POST is being sent to the GraphQL endpoint, if the body only contains queries, data will only be retrieved and not modified.

Query the inventory levels of the first ten locations where a variant is stored.

query {
  productVariant(id: "gid://shopify/ProductVariant/10782354800682") {
    inventoryItem {
      inventoryLevels (first:10) {
        edges {
          node {
            location {
              name
            }
            available
          }
        }
      }
    }
  }
}

Example Mutations

Mutations are the equivalent of REST’s data-modifying action verbs.

Increase available inventory at a location.

mutation {
  inventoryAdjustQuantity(
    input:{
      inventoryLevelId: "gid://shopify/InventoryLevel/13570506808?inventory_item_id=10820777115690"
      availableDelta: 1
    }
  )
  {
    inventoryLevel {
      available
    }
  }
}

Additional Resources

Sign up for a Partner account to get started.

Sign up