The GraphQL Endpoint
Unlike the REST Admin API which has a variety of endpoints, the GraphQL Admin API has a single endpoint:
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:
A successful query results in a response similar to the following:
Congratulations, you’ve made your first call to the GraphQL Admin API!
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:
- From your Shopify admin, select Apps.
- Click Manage private apps.
- Click Create new private app.
- Fill out the details of your private app.
- Click Save.
- 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.
To make a query to the using curl, send a POST request with your query as the JSON payload.
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.
Mutations are the equivalent of REST’s data-modifying action verbs.
Increase available inventory at a location.