RenzoDocs

Pagination

How list endpoints page with an opaque cursor, and how to know you reached the end.

View as Markdown

Every list endpoint returns one page at a time and a cursor to the next page.

Parameters

Query parameterMeaning
limitPage size. Default 20, largest 100.
cursorThe 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"
Response
{
  "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.

FieldMeaning
itemsThis page, in the endpoint's sort order.
has_moretrue when another page exists.
next_cursorSend it back as cursor for the next page. null on the last page.
limitThe page size that was applied.
total, page, page_size, total_pagesAlways 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_more is false. Then next_cursor is null.
  • An empty page has items: [] and has_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 400 invalid_cursor.
  • Keep the other parameters. Send the same filters and limit with every page. A cursor works only with the filters of the page that gave it: a cursor sent with another filter, such as another type, symbol, asset_class or q, answers 400 invalid_cursor. Start again from the first page. Date ranges and locale are 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_size or anchor_id parameters. The anchor_not_found and anchor_with_cursor codes belong to staff tools.

On this page