Pagination & filters
How to walk long lists with cursors and how to narrow results by date and status.
Shape of a list response#
Every list resource responds with the same structure: data with the results and pagination with the information to continue.
{
"data": [ /* … */ ],
"pagination": {
"cursor": "g3QAAAACZAAEZGF0YWwAAAAB…",
"has_more": true
}
}How to request the next page#
When has_more is true, pass the cursor value in the parameter of the same name. Repeat until has_more is false.
// Walk EVERY page
async function readAll(resource, params = {}) {
const all = [];
let cursor = null;
do {
const qs = new URLSearchParams({ ...params, limit: "50", ...(cursor ? { cursor } : {}) });
const res = await fetch(`https://api.r2-os.com/api/connect/v1/${resource}?${qs}`, {
headers: { Authorization: `Bearer ${process.env.R2_API_KEY}` },
});
if (!res.ok) throw new Error(`${res.status} ${(await res.json()).error.message}`);
const page = await res.json();
all.push(...page.data);
cursor = page.pagination.has_more ? page.pagination.cursor : null;
} while (cursor);
return all;
}The cursor is opaque
Do not parse or build cursors: they are internal strings whose shape may change. Use them exactly as received, and do not store them for long. For incremental syncs use created_from, not an old cursor.
Common parameters#
| Parameter | Type | Description |
|---|---|---|
| limit | integer | Results per page. Between 1 and 50. Default: 25. |
| cursor | string | Cursor for the next page, taken from pagination.cursor. |
| created_from | date | Start date, format YYYY-MM-DD (UTC) or epoch milliseconds. |
| created_to | date | End date, inclusive. Same format. |
| status | string | Filter by exact status. |
Date filters#
The created_from and created_to filters apply to the record’s creation date and accept two formats. created_to is inclusive: it covers the whole day given.
# By date (UTC)
curl -H "Authorization: Bearer YOUR_KEY" \
"https://api.r2-os.com/api/connect/v1/orders?created_from=2026-07-01&created_to=2026-07-31"
# By epoch milliseconds
curl -H "Authorization: Bearer YOUR_KEY" \
"https://api.r2-os.com/api/connect/v1/orders?created_from=1782950400000"Any format other than those two returns 400 with code bad_request.
Ordering#
Lists arrive newest first by creation date. Customers are ordered by their most recent visit.