Pagination

One cursor loop that works on every list in the API.

Every list has the same envelope:

{
  "items": [],
  "next_cursor": "eyJvIjoxMjM0NX0",
  "prev_cursor": "eyJvIjoxMjMwMH0"
}

Walk forward until next_cursor is absent:

let cursor: string | undefined;

do {
  const url = new URL('https://api.preview.avee.tech/api/v1/pairs');
  url.searchParams.set('chains', 'robinhood');
  url.searchParams.set('limit', '50');
  if (cursor) url.searchParams.set('cursor', cursor);

  const page = await (await fetch(url)).json();
  handle(page.items);
  cursor = page.next_cursor;
} while (cursor);

Rules

  • Cursors are opaque. Pass them back unchanged. Never decode or build one.
  • Absent means done. A missing next_cursor is the end of the list. An empty items with a cursor still present can happen under a sparse filter: keep walking.
  • prev_cursor walks back. On a trade tape, page into history, then use prev_cursor to catch up on what arrived meanwhile. Lists that can only page forward, such as wallet lists, omit it.
  • limit has a ceiling. Asking for more is 400 invalid_param, not a silently shorter page.
  • There is no total. Counting every match across chains costs more than the page and is stale before it arrives.

Follow a feed with time, not depth

To follow new trades, ask for what is new instead of paging to the end:

curl 'https://api.preview.avee.tech/api/v1/chains/{chain}/pairs/{address}/trades?from=1790000000&order=asc&limit=50'

Keep the last timestamp you saw and send it as the next from.

On this page