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:
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:
The following example shows a query for the first five product IDs and handles. Replace {shop}
with your store’s domain and {password}
with the access token that you generated in the Authentication section.
Example query
Anchor link to section titled "Example query"In GraphQL, queries are the equivalent of REST’s GET action verb. Queries generally begin with one of the objects listed under QueryRoot
and can get data from any connections that an object has. Even though a POST is being sent to the GraphQL endpoint, if the body only contains queries, then data is only retrieved and not modified.
The following example shows a query for the quantity of inventory items available at a location:
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:
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 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/2023-04/shop.json
endpoint. Replace {shop}
with your store’s domain and {password}
with the access token that you generated in the Authentication section.
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/2023-04/products.json
endpoint.
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 with the Customer Address
resource and the PUT /admin/api/2023-04/customers{customer_id}/addresses/{address_id}.json
endpoint.
Request:
Example DELETE
request
Anchor link to section titled "Example DELETE request"The following example illustrates how to delete an order with the Order
resource and the DELETE /admin/api/2023-04/orders/{order_id}.json
endpoint.
- Use the Shopify Admin API GraphiQL explorer to build GraphQL queries.
- Explore the GraphQL Admin API reference to learn more about the different resources and endpoints that you can access using the GraphQL Admin API.
- Explore the REST Admin API reference to learn more about the different resources and endpoints that you can access using the REST Admin API.