Guides

Pagination

Three kinds of list, each read in pages its own way. Each route in the reference says which it is.

Logs: before and next

The record and the audit log are newest first. A page holds up to limit entries and a next value; pass it back as before for the page after. next is null on the last page. Entries are append only, so a page you have read never changes.

TypeScript: read the whole record
let before: string | null = null;
do {
  const url = new URL('https://api.rykon.ai/v1/record');
  url.searchParams.set('limit', '500');
  if (before) url.searchParams.set('before', before);
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.RYKON_AI_KEY}` } });
  const page = (await res.json()) as { entries: Array<{ id: string; kind: string }>; next: string | null };
  for (const e of page.entries) console.log(e.id, e.kind);
  before = page.next;
} while (before);

Transcripts: after

A run's events are oldest first. Pass the id of the last event you have as after; an empty page means you are up to date, and a running run grows at the end, so keep asking until the run has ended.

Everything else: limit

Runs, agents, approvals and kill switches are newest first and take a limit and filters such as state. They have no cursor: narrow with filters, and use the record for a complete history.