Pagination
Paginated fields return a connection: a page of records plus information about the next page.
Request a page with first and after, then read pageInfo to decide whether to continue.
For the connection field tables, see the
Pagination reference.
The cursor loop
- Send
firstto set the page size. Omitafterfor the first page. - Read the records and
pageInfo.hasNextPage. - If
hasNextPageistrue, sendpageInfo.endCursorasafterin the next request. - Repeat until
hasNextPageisfalse.
Keep the workspace, filters, and sort order the same throughout the loop. Treat cursors as opaque strings: copy them from the response without editing or constructing them.
Select nodes to get the records directly, or edges when you need each node’s cursor. To get
the size of the full result set, request totalCount.
Page-size bounds
first defaults to 20 and must be between 1 and 100, with two exceptions:
engagementHistoryaccepts up to 1000 snapshots of one item’s metrics per page.operationRecordsaccepts up to 1000 records per page. An ID-basedrefetchEngagementBulkoperation fits in one maximum-size page. Filter-based refreshes can contain up to 10,000 records and require pagination.
Archive rejects out-of-range values with a GraphQL error. For example, first: 500 fails on a
connection capped at 100; it does not return a smaller page automatically.
Lists that are not connections
Some fields return a plain list, including saved views, Collections, and custom-attribute schemas.
These fields accept neither first nor after.
These lists are capped at 1000 rows. When a result is truncated, you get the first 1000 rows in the field’s own order, with no error and no other indication that more rows exist.
Fields with this cap include collections, contentViews, creatorViews, socialProfileViews,
viewGroups, customAttributeSchemas, labels, and webhookSubscriptions.
For subscriptions, use webhookSubscriptionsConnection when you need to paginate.
Each field’s reference page states its limit.
Walkthrough
Paginate items page by page
Fetch page one, then page two using the returned endCursor.
Step 1
query ItemsPaginationPage1($first: Int) {
items(first: $first) {
totalCount
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
} {
"first": 5
} Authorization: Bearer docs_demo_token_0000000000000000000000
WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a curl https://app.archive.com/api/v2 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer docs_demo_token_0000000000000000000000' \
-H 'WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a' \
-d '{
"query": "query ItemsPaginationPage1($first: Int) {\n items(first: $first) {\n totalCount\n edges {\n node {\n id\n caption\n takenAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}",
"variables": {
"first": 5
}
}' const response = await fetch("https://app.archive.com/api/v2", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
},
body: JSON.stringify({
query: `query ItemsPaginationPage1($first: Int) {
items(first: $first) {
totalCount
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}`,
variables: {
"first": 5
}
})
})
console.log(JSON.stringify(await response.json(), null, 2)) require "json"
require "net/http"
query = <<~'GRAPHQL'
query ItemsPaginationPage1($first: Int) {
items(first: $first) {
totalCount
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
GRAPHQL
response = Net::HTTP.post(
URI("https://app.archive.com/api/v2"),
{ query: query, variables: { "first" => 5 } }.to_json,
"Content-Type" => "application/json",
"Authorization" => "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID" => "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
)
puts response.body import json
import requests
query = """
query ItemsPaginationPage1($first: Int) {
items(first: $first) {
totalCount
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
"""
response = requests.post(
"https://app.archive.com/api/v2",
json={"query": query, "variables": {"first": 5}},
headers={
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
},
)
print(json.dumps(response.json(), indent=2)) {
"data": {
"items": {
"totalCount": 30,
"edges": [
{
"node": {
"id": "452a119f-393e-5edf-a7f7-f563294f3885",
"caption": "Reel #29 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-30T00:00:00Z"
}
},
{
"node": {
"id": "d8a538a5-8857-5c0c-b3fb-a2b83c8d2a0b",
"caption": "Post #28 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-29T00:00:00Z"
}
},
{
"node": {
"id": "330cce49-6139-5672-9c61-33fb35bc73e2",
"caption": "Short #27 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-28T00:00:00Z"
}
},
{
"node": {
"id": "a61d036b-fe79-538c-bbbb-1f97162cab3c",
"caption": "Story #26 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-27T00:00:00Z"
}
},
{
"node": {
"id": "de1860a7-2d98-5eda-8977-116583725c74",
"caption": "Reel #25 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-26T00:00:00Z"
}
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE="
}
}
}
} Step 2
query ItemsPaginationPage2($first: Int, $after: String) {
items(first: $first, after: $after) {
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
} {
"first": 5,
"after": "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE="
} Authorization: Bearer docs_demo_token_0000000000000000000000
WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a curl https://app.archive.com/api/v2 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer docs_demo_token_0000000000000000000000' \
-H 'WORKSPACE-ID: 6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a' \
-d '{
"query": "query ItemsPaginationPage2($first: Int, $after: String) {\n items(first: $first, after: $after) {\n edges {\n node {\n id\n caption\n takenAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}",
"variables": {
"first": 5,
"after": "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE="
}
}' const response = await fetch("https://app.archive.com/api/v2", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
},
body: JSON.stringify({
query: `query ItemsPaginationPage2($first: Int, $after: String) {
items(first: $first, after: $after) {
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}`,
variables: {
"first": 5,
"after": "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE="
}
})
})
console.log(JSON.stringify(await response.json(), null, 2)) require "json"
require "net/http"
query = <<~'GRAPHQL'
query ItemsPaginationPage2($first: Int, $after: String) {
items(first: $first, after: $after) {
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
GRAPHQL
response = Net::HTTP.post(
URI("https://app.archive.com/api/v2"),
{ query: query, variables: { "first" => 5, "after" => "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE=" } }.to_json,
"Content-Type" => "application/json",
"Authorization" => "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID" => "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a"
)
puts response.body import json
import requests
query = """
query ItemsPaginationPage2($first: Int, $after: String) {
items(first: $first, after: $after) {
edges {
node {
id
caption
takenAt
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
"""
response = requests.post(
"https://app.archive.com/api/v2",
json={"query": query, "variables": {"first": 5, "after": "Z2lkOi8vYXJjaGl2ZS9JdGVtL2RlMTg2MGE3LTJkOTgtNWVkYS04OTc3LTExNjU4MzcyNWM3NDpXeUpqTVdRNU9UQTVOU0lzV3pFM016STFOemt5TURBd01EQXNJbVJsTVRnMk1HRTNMVEprT1RndE5XVmtZUzA0T1RjM0xURXhOalU0TXpjeU5XTTNOQ0pkWFE="}},
headers={
"Authorization": "Bearer docs_demo_token_0000000000000000000000",
"WORKSPACE-ID": "6ccefa76-e8ba-5ab0-9c60-e48a9e235a4a",
},
)
print(json.dumps(response.json(), indent=2)) {
"data": {
"items": {
"edges": [
{
"node": {
"id": "3870b3f7-2066-56c1-b82e-f7c606c863fa",
"caption": "Post #24 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-25T00:00:00Z"
}
},
{
"node": {
"id": "2adb5caf-5619-5fc5-b738-ba264cb394a7",
"caption": "Short #23 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-24T00:00:00Z"
}
},
{
"node": {
"id": "5b570218-bf6a-5e05-9389-2f9bfe7f73ce",
"caption": "Story #22 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-23T00:00:00Z"
}
},
{
"node": {
"id": "24bd35e7-4ae8-546b-bc76-b9cee5e1107f",
"caption": "Reel #21 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-22T00:00:00Z"
}
},
{
"node": {
"id": "5503f877-fd11-5373-b372-ce4738980780",
"caption": "Post #20 from Northwind Botanicals #northwindbotanicals #plantcare #growwithnorthwind @northwindbotanicals",
"takenAt": "2024-11-21T00:00:00Z"
}
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "Z2lkOi8vYXJjaGl2ZS9JdGVtLzU1MDNmODc3LWZkMTEtNTM3My1iMzcyLWNlNDczODk4MDc4MDpXeUpqTVdRNU9UQTVOU0lzV3pFM016SXhORGN5TURBd01EQXNJalUxTURObU9EYzNMV1prTVRFdE5UTTNNeTFpTXpjeUxXTmxORGN6T0RrNE1EYzRNQ0pkWFE="
}
}
}
} For the connection and PageInfo field tables, see the
Pagination reference.