Getting started with the GraphQL Admin and REST Admin APIs
The GraphQL Admin and REST Admin APIs let you build apps and other integrations for the Shopify admin using GraphQL or REST. With the APIs, you can create apps that offer functionality at every stage of a store's operation, including shipping, fulfillment, and product management.
Authentication
Anchor link to section titled "Authentication"The GraphQL Admin and REST Admin APIs require a Shopify access token (for public apps and custom apps) for making authenticated requests.
To get the access token for a public or custom app, follow the OAuth authorization flow in the OAuth guide. Include the access token as a X-Shopify-Access-Token
header in your requests.
If you created your custom app in the Shopify admin, then you need to authenticate the app with access tokens. This is applicable only to custom apps created in the Shopify admin.
GraphQL Admin API
Anchor link to section titled "GraphQL Admin API"The GraphQL Admin API is a GraphQL-based alternative to the REST-based Admin API, and makes the functionality of the Shopify admin available at a single GraphQL endpoint:
POST https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
You can access the GraphQL Admin API using the GraphiQL app, curl, or any HTTP client:
Use the GraphiQL app
Anchor link to section titled "Use the GraphiQL app"We recommend installing Shopify’s own GraphiQL app to explore your shop’s data using the GraphQL Admin API. After you've installed the app, you can test it by running the following query:
POST https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
View response
The following example shows a query for the first 5 product IDs and handles. Replace {shop}
with your store’s domain and {password}
with the access token you generated in the Authentication section.
POST https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
View response
Example query
Anchor link to section titled "Example query"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, then data will only be retrieved and not modified.
The following example shows a query for the quantity of inventory items available at a location:
POST https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
View response
Example mutation
Anchor link to section titled "Example mutation"Mutations are the equivalent of REST’s data-modifying action verbs, such as PUT or DELETE. The following example shows a mutation that increases the available inventory at a location:
POST https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
View response
REST Admin API
Anchor link to section titled "REST Admin API"You can access the REST Admin API using curl or any other HTTP client. REST Admin API endpoints are organized by resource type. You'll need to use different API endpoints depending on the service that your app provides.
Example GET
request using curl
Anchor link to section titled "Example GET request using curl"The following curl request retrieves information by using the Shop resource and the GET /admin/api/2022-04/shop.json
endpoint. Replace {shop}
with your store’s domain and {password}
with the access token you generated in the Authentication section.
Request:
View response
Example POST
request
Anchor link to section titled "Example POST request"The following example illustrates how to create a product that has a draft status by using the Product resource and the POST /admin/api/2022-04/products.json
endpoint.
Request:
POST https://{shop}.myshopify.com/admin/api/2022-04/products.json
View response
Example PUT
request
Anchor link to section titled "Example PUT request"The following example illustrates how to update the postal code of a customer address by using the Customer Address resource and the PUT /admin/api/2022-04/customers{customer_id}/addresses/{address_id}.json
endpoint.
Request:
PUT /admin/api/2022-04/customers/207119551/addresses/207119551.json
View response
Example DELETE
request
Anchor link to section titled "Example DELETE request"The following example illustrates how to delete an order by using the Order resource and the DELETE /admin/api/2022-04/orders/{order_id}.json
endpoint.
Request:
DELETE /admin/api/2021-01/orders/450789469.json
View response
- Shopify admin API GraphiQL explorer: Use the GraphiQL explorer to build GraphQL queries.
- GraphQL Admin API reference: Explore the different resources and endpoints you can access using the GraphQL Admin API.
- REST Admin API reference: Explore the different resources and endpoints you can access using the REST Admin API.