Make your first API call
Create an app, install it on your development store, get an access token and read the store with the Admin API.
This guide takes about ten minutes. You need a partner organization and a development store. The code runs on your computer; nothing needs to be deployed yet.
1. Create the app
- In the partner dashboard, open Apps and select Create app.
- Fill in App name. Handle is optional: it is made from the name and becomes the app's address in the store dashboard.
- Select Create app. A dialog, Save your client secret, shows the Client ID and the Client secret. The secret is shown only this once: put it in your secret store now, then select I saved the secret.




2. Configure it
Open Configuration:
- App URL: the page the store dashboard opens, for example
https://example.com/app. - Redirect URLs: where Tanqory sends the merchant back after the install, for example
https://example.com/auth/callback. Select Add redirect URL. You can add up to 10. - Access scopes, Required: select Add scope, search for
read_productsand pick it. Addwrite_productsthe same way. - Select Save version.




The app's Home now lists its OAuth endpoints: the authorize address for each of your development stores, the token address and the session keys.
3. Install it on your development store
An install is the OAuth 2.0 authorization code grant with PKCE (RFC 6749, RFC 7636). Make a state value and a code verifier, keep both, and send the merchant (here, you) to the authorize address.
Set these in your shell first:
export STORE_ID=<the store id from the store dashboard address>
export TANQORY_CLIENT_ID=<your client ID>
export TANQORY_CLIENT_SECRET=<your client secret>// Node.js 18 or later: the values for one install. Keep state and verifier until the callback.
import { createHash, randomBytes } from 'node:crypto';
const state = randomBytes(16).toString('hex');
const verifier = randomBytes(32).toString('base64url');
const challenge = createHash('sha256').update(verifier).digest('base64url');
const url = new URL(`https://admin.tanqory.com/admin/store/${process.env.STORE_ID}/oauth/authorize`);
url.search = new URLSearchParams({
client_id: process.env.TANQORY_CLIENT_ID,
scope: 'read_products,write_products',
redirect_uri: 'https://example.com/auth/callback',
state,
code_challenge: challenge,
code_challenge_method: 'S256',
});
console.log(JSON.stringify({ state, verifier, url: url.href }));# Python 3: the values for one install. Keep state and verifier until the callback.
import base64, hashlib, json, os, secrets
from urllib.parse import urlencode
state = secrets.token_hex(16)
verifier = secrets.token_urlsafe(32)
challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode()
url = f"https://admin.tanqory.com/admin/store/{os.environ['STORE_ID']}/oauth/authorize?" + urlencode({
"client_id": os.environ["TANQORY_CLIENT_ID"],
"scope": "read_products,write_products",
"redirect_uri": "https://example.com/auth/callback",
"state": state,
"code_challenge": challenge,
"code_challenge_method": "S256",
})
print(json.dumps({"state": state, "verifier": verifier, "url": url}))Open the printed url in the browser where you are signed in to the store dashboard. The page Authorize app names your app and organization and lists what the app will be able to do. Select Install app.


The browser goes to your redirect URL with six query parameters: code, hmac, shop, state, store_id and timestamp. Copy the address from the browser; your page does not need to exist yet.
4. Check the callback and exchange the code
Before you use the code, check that the callback comes from Tanqory: state must be the value you made, and hmac must be the hex HMAC-SHA256 of the other parameters, sorted by name and joined as name=value&name=value, keyed with your client secret.
import { createHmac, timingSafeEqual } from 'node:crypto';
// query: the callback's query string, for example new URL(req.url, 'https://example.com').search
export function callbackIsFromTanqory(query, clientSecret) {
const params = new URLSearchParams(query);
const message = [...params]
.filter(([key]) => key !== 'hmac')
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
.map(([key, value]) => `${key}=${value}`)
.join('&');
const expected = createHmac('sha256', clientSecret).update(message).digest('hex');
const given = params.get('hmac') ?? '';
return given.length === expected.length && timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}import hashlib, hmac
from urllib.parse import parse_qsl
def callback_is_from_tanqory(query: str, client_secret: str) -> bool:
params = dict(parse_qsl(query.lstrip("?"), keep_blank_values=True))
given = params.pop("hmac", "")
message = "&".join(f"{key}={value}" for key, value in sorted(params.items()))
expected = hmac.new(client_secret.encode(), message.encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(given, expected)Then exchange the code for an access token. A code works once and only with the verifier of the same install.
export CODE=<code from the callback>
export CODE_VERIFIER=<verifier from step 3>curl -X POST "https://api.tanqory.com/v1/stores/$STORE_ID/apps/oauth/token" \
--data-urlencode "client_id=$TANQORY_CLIENT_ID" \
--data-urlencode "client_secret=$TANQORY_CLIENT_SECRET" \
--data-urlencode "grant_type=authorization_code" \
--data-urlencode "code=$CODE" \
--data-urlencode "code_verifier=$CODE_VERIFIER" \
--data-urlencode "redirect_uri=https://example.com/auth/callback"// Node.js 18 or later. Save as exchange.mjs and run: node exchange.mjs
const res = await fetch(`https://api.tanqory.com/v1/stores/${process.env.STORE_ID}/apps/oauth/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
client_id: process.env.TANQORY_CLIENT_ID,
client_secret: process.env.TANQORY_CLIENT_SECRET,
grant_type: 'authorization_code',
code: process.env.CODE,
code_verifier: process.env.CODE_VERIFIER,
redirect_uri: 'https://example.com/auth/callback',
}),
});
console.log(res.status, await res.json()); // { access_token, scope, store_id, token_type: 'Bearer' }# Python 3, standard library only. Save as exchange.py and run: python3 exchange.py
import json, os, urllib.parse, urllib.request
req = urllib.request.Request(
f"https://api.tanqory.com/v1/stores/{os.environ['STORE_ID']}/apps/oauth/token",
data=urllib.parse.urlencode({
"client_id": os.environ["TANQORY_CLIENT_ID"],
"client_secret": os.environ["TANQORY_CLIENT_SECRET"],
"grant_type": "authorization_code",
"code": os.environ["CODE"],
"code_verifier": os.environ["CODE_VERIFIER"],
"redirect_uri": "https://example.com/auth/callback",
}).encode(),
)
with urllib.request.urlopen(req) as res:
print(res.status, json.load(res))The answer holds access_token, token_type (Bearer), scope (the granted scopes, separated by spaces) and store_id, and no expiry time. Keep the token on your server, one per store.
5. Call the Admin API
- Your app server → Tanqory edge POST /admin/<version>/stores/<store id>/graphql with Authorization: Bearer If not: 404 for any other path
- Tanqory edge → Admin API To the servers that hold that store
- Admin API The version exists If not: 404
- Admin API The token is valid for this store If not: 401
- Admin API The store exists and the token may use it If not: 404
- Admin API The query parses and is valid If not: 400 GRAPHQL_PARSE_FAILED or GRAPHQL_VALIDATION_FAILED
- Admin API Every field is within the granted scopes If not: 200 with ACCESS_DENIED
- Admin API The query cost fits, and the bucket has enough points If not: 200 with MAX_COST_EXCEEDED or THROTTLED and Retry-After
- Admin API Runs the query
- Admin API → Your app server data, and extensions.cost with what is left in the bucket
export TANQORY_ACCESS_TOKEN=<access_token from step 4>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": "{ shop { name currencyCode } }"}'// Node.js 18 or later. Save as first-call.mjs and run: node first-call.mjs
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: '{ shop { name currencyCode } }' }),
});
console.log(res.status, await res.json());# Python 3, standard library only. Save as first_call.py and run: python3 first_call.py
import json, os, urllib.request
req = urllib.request.Request(
f"https://api.tanqory.com/admin/2026-10/stores/{os.environ['STORE_ID']}/graphql",
data=json.dumps({"query": "{ shop { name currencyCode } }"}).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:
{
"data": { "shop": { "name": "Docs Writer Store", "currencyCode": "THB" } },
"extensions": {
"cost": {
"requestedQueryCost": 1,
"actualQueryCost": 1,
"throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 999, "restoreRate": 100 }
}
}
}extensions.cost is what the request used from your rate limit; see Rate limits and query cost.
Next
- Install and access tokens: every parameter, reinstalling, and the install from inside the dashboard.
- API reference: every query and mutation, with the scope each one needs.