Skip to main content
Back to App

Pagination

Every list endpoint in the Conviction API uses offset-based pagination. It's not a cursor or page-number model.

#Query parameters

NameTypeDescriptionDefault
limitnumberNumber of items to fetch at once.20 (or varies by endpoint)
offsetnumberNumber of items to skip.0

limit is generally capped between 1 and 100 (the upper bound varies by endpoint).

#Response envelope

{
  "markets": [ /* ... */ ],
  "total": 347,
  "limit": 20,
  "offset": 0
}
FieldDescription
markets (or orders, deposits...)The actual data array. The key name varies by endpoint.
totalTotal number of items after filters are applied
limitThe value received in the request (or the applied default)
offsetThe value received in the request (or 0)

#Next page

There's no separate next URL. The client computes it itself.

const nextOffset = currentOffset + limit;
if (nextOffset >= total) {
  // done
}

#Infinite-scroll pattern

function buildUrl(offset: number, limit: number) {
  const url = new URL('https://api.conviction.bet/v1/markets');
  url.searchParams.set('status', 'ACTIVE');
  url.searchParams.set('limit', limit.toString());
  url.searchParams.set('offset', offset.toString());
  return url.toString();
}
 
let offset = 0;
const limit = 20;
const all = [];
while (true) {
  const res = await fetch(buildUrl(offset, limit)).then((r) => r.json());
  all.push(...res.markets);
  if (offset + limit >= res.total) break;
  offset += limit;
}

#Sorting

List endpoints usually accept sortBy and sortOrder together. For the available values, consult each endpoint's spec.

#Next

Was this page helpful?