Pagination
How list endpoints page with an opaque cursor, and how to know you reached the end.
Every list endpoint returns one page at a time and a cursor to the next page.
Parameters
| Query parameter | Meaning |
|---|---|
limit | Page size. Default 20, largest 100. |
cursor | The next_cursor of the page before. Leave it out for the first page. |
A limit over 100 answers 422 validation_failed. It is not cut down to 100. A limit under 1 fails the same way.
One endpoint has other numbers: GET /api/v1/market-data/{slug}/bars defaults to 400 bars and allows up to 1000.
The page
curl "$BASE/api/v1/articles?limit=2"{
"items": [
{ "id": "f43679d3-0ab5-5f68-8bda-f0a4c5560594", "slug": "fed-holds-rates-steady-as-inflation-cools" },
{ "id": "3b1e0c55-2f0e-5d7b-9a3c-0e4f8c1d2a6b", "slug": "oil-slips-on-supply-outlook" }
],
"has_more": true,
"next_cursor": "eyJrIjoiMjAyNi0xMS0wNFQxMzozMDowMFoifQ",
"limit": 2,
"total": null,
"page": null,
"page_size": null,
"total_pages": null
}The items above are trimmed.
| Field | Meaning |
|---|---|
items | This page, in the endpoint's sort order. |
has_more | true when another page exists. |
next_cursor | Send it back as cursor for the next page. null on the last page. |
limit | The page size that was applied. |
total, page, page_size, total_pages | Always null on this API. They exist for numbered pages in Renzo's staff tools. |
Walk every page
curl "$BASE/api/v1/articles?limit=100"
# then, for each next page:
curl "$BASE/api/v1/articles?limit=100&cursor=eyJrIjoiMjAyNi0xMS0wNFQxMzozMDowMFoifQ"Rules
- The end. Stop when
has_moreisfalse. Thennext_cursorisnull. - An empty page has
items: []andhas_more: false. It is not an error. - The cursor is opaque. Pass it back exactly as you got it. Do not build, edit or decode it. A changed or broken cursor answers
400invalid_cursor. - Keep the other parameters. Send the same filters and
limitwith every page. A cursor works only with the filters of the page that gave it: a cursor sent with another filter, such as anothertype,symbol,asset_classorq, answers400invalid_cursor. Start again from the first page. Date ranges andlocaleare not part of this check. - New rows while you page. The cursor marks a place in the sort order, so you do not see a row twice. A row added before your place appears only when you start again from the first page.
- No anchors. Public lists have no
page,page_sizeoranchor_idparameters. Theanchor_not_foundandanchor_with_cursorcodes belong to staff tools.