Storefront API
Read a store's catalog and build carts from your own site or app, with a storefront access token your app creates.
The Storefront API is the API for what buyers see: products, collections, pages, search, carts and checkout links. It answers on the store's own domain and takes a storefront access token, which your app creates with the Admin API. That token only reads what the store shows to every visitor and builds carts, so it is not a secret in the way your Admin API token is.
Before you start
You need an app installed on a store and its Admin API access token, as in Make your first API call, and the store's domain. Read the domain with the Admin API:
{ shop { primaryDomain { host } } }{ "data": { "shop": { "primaryDomain": { "host": "docs-writer-store.mytanqory.com" } } } }1. Create a storefront access token
Call storefrontAccessTokenCreate with your app's Admin API token. It needs no access scope of its own.
curl -X POST "https://api.tanqory.com/admin/2026-10/stores/$STORE_ID/graphql" \
-H "Authorization: Bearer $TANQORY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data '{"query": "mutation { storefrontAccessTokenCreate(input: { title: \"My storefront\" }) { storefrontAccessToken { accessToken accessScopes { handle } } userErrors { field message } } }"}'// Node.js 18 or later. Save as storefront-token.mjs and run: node storefront-token.mjs
const query = 'mutation { storefrontAccessTokenCreate(input: { title: "My storefront" }) { storefrontAccessToken { accessToken accessScopes { handle } } userErrors { field message } } }';
const res = await fetch(`https://api.tanqory.com/admin/2026-10/stores/${process.env.STORE_ID}/graphql`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.TANQORY_ACCESS_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
});
console.log(res.status, JSON.stringify(await res.json()));# Python 3, standard library only. Save as storefront_token.py and run: python3 storefront_token.py
import json, os, urllib.request
query = 'mutation { storefrontAccessTokenCreate(input: { title: "My storefront" }) { storefrontAccessToken { accessToken accessScopes { handle } } userErrors { field message } } }'
req = urllib.request.Request(
f"https://api.tanqory.com/admin/2026-10/stores/{os.environ['STORE_ID']}/graphql",
data=json.dumps({"query": query}).encode(),
headers={"Authorization": f"Bearer {os.environ['TANQORY_ACCESS_TOKEN']}", "Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(res.status, json.load(res))The answer (the token shortened here):
{
"data": {
"storefrontAccessTokenCreate": {
"storefrontAccessToken": {
"accessToken": "e1c3…",
"accessScopes": [
{ "handle": "unauthenticated_read_product_listings" },
{ "handle": "unauthenticated_write_checkouts" },
{ "handle": "unauthenticated_read_checkouts" },
{ "handle": "unauthenticated_read_selling_plans" }
]
},
"userErrors": []
}
}
}2. Call the Storefront API
POST https://<store domain>/api/v1/stores/<store id>/2026-10/graphql, with the token in X-Tanqory-Storefront-Access-Token. On the store's own domain the short address https://<store domain>/api/2026-10/graphql.json (or /graphql) is the same API for that store, with no store id:
export TANQORY_STOREFRONT_TOKEN=<accessToken from step 1>
export STORE_HOST=<host from "Before you start">
curl -X POST "https://$STORE_HOST/api/v1/stores/$STORE_ID/2026-10/graphql" \
-H "X-Tanqory-Storefront-Access-Token: $TANQORY_STOREFRONT_TOKEN" \
-H "Content-Type: application/json" \
--data '{"query": "{ shop { name } products(first: 2) { nodes { title handle variants(first: 1) { nodes { id price { amount currencyCode } } } } } }"}'// Node.js 18 or later. Save as storefront.mjs and run: node storefront.mjs
const query = '{ shop { name } products(first: 2) { nodes { title handle variants(first: 1) { nodes { id price { amount currencyCode } } } } } }';
const res = await fetch(`https://${process.env.STORE_HOST}/api/v1/stores/${process.env.STORE_ID}/2026-10/graphql`, {
method: 'POST',
headers: { 'X-Tanqory-Storefront-Access-Token': process.env.TANQORY_STOREFRONT_TOKEN, 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
});
console.log(res.status, JSON.stringify(await res.json()));# Python 3, standard library only. Save as storefront.py and run: python3 storefront.py
import json, os, urllib.request
query = "{ shop { name } products(first: 2) { nodes { title handle variants(first: 1) { nodes { id price { amount currencyCode } } } } } }"
req = urllib.request.Request(
f"https://{os.environ['STORE_HOST']}/api/v1/stores/{os.environ['STORE_ID']}/2026-10/graphql",
data=json.dumps({"query": query}).encode(),
headers={"X-Tanqory-Storefront-Access-Token": os.environ["TANQORY_STOREFRONT_TOKEN"], "Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as res:
print(res.status, json.load(res))The answer:
{
"data": {
"shop": { "name": "Docs Writer Store" },
"products": {
"nodes": [
{ "title": "Linen Throw", "handle": "linen-throw", "variants": { "nodes": [{ "id": "gid://tanqory/ProductVariant/01a1dcb0-711d-72b3-b72f-032093b8ec7a", "price": { "amount": "2490.0", "currencyCode": "THB" } }] } },
{ "title": "Tall Stoneware Vase", "handle": "stoneware-vase", "variants": { "nodes": [{ "id": "gid://tanqory/ProductVariant/01a1dcb0-7616-7203-9e69-2c2c34fd9f67", "price": { "amount": "1290.0", "currencyCode": "THB" } }] } }
]
}
}
}3. Create a cart
Pass a variant id from step 2 as merchandiseId:
mutation CreateCart($lines: [CartLineInput!]) {
cartCreate(input: { lines: $lines }) {
cart { id checkoutUrl totalQuantity cost { totalAmount { amount currencyCode } } }
userErrors { field message }
}
}{ "lines": [{ "merchandiseId": "gid://tanqory/ProductVariant/01a1dcb0-711d-72b3-b72f-032093b8ec7a", "quantity": 1 }] }The answer holds the cart and its checkoutUrl, on the store's own domain:
{
"data": {
"cartCreate": {
"cart": {
"id": "gid://tanqory/Cart/c1-5c39da09b860e971a6d65b8ddedb36cf?key=4a71176a3c676c9200d6a848e2609166",
"checkoutUrl": "https://docs-writer-store.mytanqory.com/cart/c/c1-5c39da09b860e971a6d65b8ddedb36cf?key=4a71176a3c676c9200d6a848e2609166",
"totalQuantity": 1,
"cost": { "totalAmount": { "amount": "2490.0", "currencyCode": "THB" } }
},
"userErrors": []
}
}
}Send the buyer to checkoutUrl to pay. Keep the cart id, with its key, to add lines later with cartLinesAdd.
Errors
A missing token, a token that is not valid, or one of another store answers HTTP 401, before GraphQL runs:
{"error":{"code":"invalid_access_token","message":"Send a valid access token in the X-Tanqory-Storefront-Access-Token header. The token sent is missing, not valid, or belongs to another store.","status":401}}Everything else is a GraphQL answer, described in Errors.
Good to know
- Password-protected stores. A store's password closes its online store pages, not its Storefront API. New stores, development stores among them, start password-protected, and the API answers there with a valid token.
- Where to call it from. From your server, or from a browser on any domain: the API answers the browser's cross-origin preflight and lets any page read its answers (
Access-Control-Allow-Origin: *, no cookies). A browser may send only the publicX-Tanqory-Storefront-Access-Token, never the private token, which is for servers. - Versions. Name a version in the URL, as above.
/api/v1/stores/<store id>/graphqlwithout a version serves the newest one and moves on with each release; see Versioning. - What the token opens. The public scopes listed in step 1: published products and collections, carts and checkout links, and selling plans. Nothing about customers or orders, and nothing that changes the store.
- The Storefront API reference lists every query, mutation and type.