Conventions
Pagination
Every list returns the same page shape and walks it with opaque cursors.
Every list endpoint answers with the same envelope:
{
"data": [{ "id": "…" }, { "id": "…" }],
"nextCursor": "c1_WyIyMDI2LTEwLTIxVDA5OjEyOjQ0LjAwMFoiLCI5YjJm…",
"prevCursor": null
}Lists are newest first, ordered by creation time and then id, so a page never skips or repeats a row even when new ones arrive while you are paging.
| Query parameter | |
|---|---|
limit | Page size, 1 to 100. Default 25. |
after | A nextCursor from the previous page: continue to older items. |
before | A prevCursor: go back to newer items. Send after or before, not both. |
nextCursor is null on the last page; prevCursor is null on the first.
Cursors are opaque. Pass them back exactly as you got them. Do not build, parse or store them
long-term; their format can change. A string that is not a cursor Gauge issued answers
400 validation_failed.
Fetch every page
async function* listAll(path) {
let after = null;
do {
const url = new URL(`https://app.gauge.chat/backend${path}`);
url.searchParams.set('limit', '100');
if (after) url.searchParams.set('after', after);
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.GAUGE_API_KEY}` } });
const page = await res.json();
if (!res.ok) throw new Error(`${page.error.code} (${page.error.requestId})`);
yield* page.data;
after = page.nextCursor;
} while (after);
}
for await (const connection of listAll('/v2/connections')) console.log(connection.displayName);Paging through a large list spends one request per page against your
rate limit. Use limit=100 for bulk reads.