API Connector Documentation
Import Shopify GraphQL Data to Google Sheets
The main Shopify tutorial uses the REST API because it's easier to navigate and supports standard pagination methods. Shopify also provides a GraphQL API, which allows more specificity in terms of the fields that you retrieve and can be convenient in some cases.
Related: Import Shopify Data to Google Sheets
Step-by-Step GraphQL Example
Below is an example of how to fetch data from Shopify's GraphQL API into Sheets with API Connector.
- Create your graphQL query and enter it into a cell, let's say cell A1 of a sheet called Input. Here is an example of a valid graphQL query:
query myQuery { orders(first: 50) { edges { cursor node { createdAt id name email displayFulfillmentStatus lineItems(first: 10) { edges { node { quantity title } } } } } pageInfo { hasNextPage } } }
- Encode the whole block by creating a new cell with this formula:
=ENCODEURL(A1)
- Back in the API Connector sidebar, choose the
POST
method. - Enter a request URL that references your encoded cell, like this:
https://your_shop_name.myshopify.com/admin/api/2023-04/graphql.json?query=+++Input!A3+++
- Under Headers, enter the following (get your API token as described here):
X-Shopify-Access-Token your_api_token Content-type application/json - In the request body, enter
{}
(we don't need aPOST
body here but it can't be empty) - Click Run to see the results in your sheet.
Notes
- GraphQL query builder tool: https://shopify.dev/apps/tools/graphiql-admin-api
- API Connector's standard pagination handling methods will not work here since GraphQL uses a different method of pagination, described here.