Skip to main content

Pagination

Endpoints that list resources (actors, runs, tasks, schedules, webhooks, listening mentions…) return one page at a time.

Page and per_page​

ParameterTypeDefaultDescription
pageinteger ≥ 11The page to return.
per_pageinteger, at most 100Depends on the endpointItems per page.
Second page of 50 runs
curl "https://lantfly.com/api/v3/runs?page=2&per_page=50" \
-H "Authorization: Bearer $LANTFLY_TOKEN"

The answer carries the items in data and the position in meta:

Paged answer
{
"data": [ { "id": "…", "status": "SUCCEEDED" } ],
"meta": {
"current_page": 2,
"last_page": 7,
"per_page": 50,
"total": 318
}
}
meta fieldDescription
current_pageThe page you got.
last_pageThe last page there is.
per_pageItems per page used.
totalItems across all pages.

Read every page​

all_runs.py
import os
import requests

session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['LANTFLY_TOKEN']}"

page, runs = 1, []
while True:
res = session.get(
"https://lantfly.com/api/v3/runs",
params={"page": page, "per_page": 100},
timeout=30,
)
res.raise_for_status()
body = res.json()
runs.extend(body["data"])
if page >= body["meta"]["last_page"]:
break
page += 1

print(len(runs), "runs")
note

A few lists return everything when you send neither page nor per_page, and page only when you ask for it: for example a listening project's sources and collections. Each endpoint's maximum per_page is in the API reference.

Storage content​

Storage content can hold millions of entries, so it pages differently.

WhatParametersNext page
Dataset items, GET /datasets/{id}/itemsoffset, limit, descoffset + count. meta holds total, offset, limit, count, desc; the same values are in X-Lantfly-Pagination-Total, -Offset, -Limit, -Count and -Desc headers.
Key-value store keys, GET /key-value-stores/{id}/keyslimit (at most 1,000), exclusive_start_keySend meta.next_exclusive_start_key while meta.is_truncated is true.
Request queue requests, GET /request-queues/{id}/requestslimit (at most 10,000), cursor, handledSend meta.next_cursor until it's empty.

Dataset limit is capped at 250,000 items for json, jsonl and csv (streamed) and 20,000 for xlsx, html, xml and rss. A larger limit is lowered to the cap without an error. See Datasets.