Pagination
Lists in the Admin API come in pages. Ask for a page size, then follow the cursor.
A field that returns many items, such as products or orders, is a connection: it returns one page at a time, and you ask for the next page with a cursor. Connections follow the GraphQL Cursor Connections Specification.
- Your app server → Admin API products(first: 10)
- Admin API first is 250 at most If not: an error, invalid_pagination_argument
- Admin API → Your app server 10 edges, hasNextPage: true, endCursor
- Your app server → Admin API products(first: 10, after: endCursor)
- Admin API → Your app server The next 10, hasNextPage: true, a new endCursor
- Your app server → Admin API products(first: 10, after: the new endCursor)
- Admin API → Your app server The last items, hasNextPage: false
- Your app server Stops
Ask for a page
query Products($after: String) {
products(first: 10, after: $after) {
edges { node { id title } }
pageInfo { hasNextPage endCursor }
}
}| Argument | Meaning |
|---|---|
first | How many items, counted from the start or from after |
after | The endCursor of the page before; leave it out for the first page |
last, before | The same backwards, from the end or from before |
query, sortKey, reverse | Filter and order, where the field offers them; see its page in the reference |
The answer:
{
"data": {
"products": {
"edges": [
{ "node": { "id": "gid://tanqory/Product/01a1dcb0-7022-7580-86b0-ad652431da0b", "title": "Linen Throw" } }
],
"pageInfo": { "hasNextPage": true, "endCursor": "eyJsYXN0X2lkIjoi..." }
}
}
}pageInfo also has hasPreviousPage and startCursor. Each edge can return its own cursor too.
Read every page
While hasNextPage is true, send the same query with after set to the last endCursor:
// Node.js 18 or later: every product title, 10 at a time.
const url = `https://api.tanqory.com/admin/2026-10/stores/${process.env.STORE_ID}/graphql`;
const query = `query Products($after: String) {
products(first: 10, after: $after) {
edges { node { id title } }
pageInfo { hasNextPage endCursor }
}
}`;
let after = null;
do {
const res = await fetch(url, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.TANQORY_ACCESS_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ query, variables: { after } }),
});
const { data, errors } = await res.json();
if (errors) throw new Error(errors[0].message);
for (const { node } of data.products.edges) console.log(node.title);
after = data.products.pageInfo.hasNextPage ? data.products.pageInfo.endCursor : null;
} while (after);# Python 3, standard library only: every product title, 10 at a time.
import json, os, urllib.request
URL = f"https://api.tanqory.com/admin/2026-10/stores/{os.environ['STORE_ID']}/graphql"
QUERY = """query Products($after: String) {
products(first: 10, after: $after) {
edges { node { id title } }
pageInfo { hasNextPage endCursor }
}
}"""
after = None
while True:
req = urllib.request.Request(URL, data=json.dumps({"query": QUERY, "variables": {"after": after}}).encode(), headers={
"Authorization": f"Bearer {os.environ['TANQORY_ACCESS_TOKEN']}",
"Content-Type": "application/json",
})
with urllib.request.urlopen(req) as res:
body = json.load(res)
if "errors" in body:
raise SystemExit(body["errors"][0]["message"])
for edge in body["data"]["products"]["edges"]:
print(edge["node"]["title"])
page = body["data"]["products"]["pageInfo"]
if not page["hasNextPage"]:
break
after = page["endCursor"]Both print the title of every product in the store, ten per request.
Good to know
Treat a cursor as opaque: store it and send it back, never build or change one.
Bigger pages cost more of your rate limit; see Rate limits and query cost.
extensions.costin each answer shows what a page used.To count without reading every page, use a count field where one exists, such as
productsCount { count }.firstandlasttake at most 250; more is aninvalid_pagination_argumenterror.