Public API pagination
Read a Costfluent Public API list one page at a time with page and limit, and follow its links to the next page.
Every list operation answers with the same envelope: the page's items in data, and links to the neighbouring pages in links. Cost data adds what the whole query covers in meta.
Read a list page by page
- Request the first page with
page=1and thelimityou want. - Process
data. - When
links.nextis set, request that link; it keeps every filter of the first request. When it isnull, that was the last page.
Code
Code
Page size
| Operation | limit | Default |
|---|---|---|
| Every list, such as budgets, cost reports or integrations | 1 to 100; a larger or smaller value is held to that range | 20 |
Business metric values, GET /v1/business-metrics/{metricId}/values | 1 to 1,000; a larger or smaller value is held to that range | 20 |
Cost data, GET /v1/costs | 1 to 5,000; a value outside that range is refused with 400 | 20 |
page and limit are optional on every list. The API reference states each operation's range in the parameter's description and its default beside it.
Reading cost data in bulk
Cost data is the one bulk read: ask for limit=5000 to read a window in as few requests as possible. Paging reaches 100,000 rows, page × limit; a request past that is refused with 400, and its error says to split the date window. Read a large window as several shorter startDate to endDate ranges, each from page 1.
meta.totalRecords counts every row the query matches, so meta.totalRecords divided by limit tells you how many pages to expect before you start.
Notice a sync between pages
Each page is read from the data as it stands when you request it. When a sync lands while you walk the pages, rows move: a later page can repeat a row you already have, or skip one. To notice, send the meta.dataVersion of your first page as dataVersion with every later page. The links of a request that sends it carry it, so following links.next keeps it.
Code
A page whose data a sync changed since your first page is refused with 409 and the code conflict. Read the window again from page 1 without dataVersion, and send the new first page's version from then on. A dataVersion that is not 16 lowercase hexadecimal characters, the form every version takes, is refused with 400. Without dataVersion, every page is served as before.
How it behaves
pagestarts at 1. A page past the end answers200with an emptydata.- Paging reaches 2,147,483,646 items,
page × limit; a page past that is refused with400, avalidation_failederror namingpage. links.lastisnullwhen the total is not known.