Skip to main content
Back to App

Pagination

The public API has one list endpoint, GET /v1/markets, and it uses offset-based pagination. It's not a cursor or page-number model.

#Query parameters

NameTypeDescriptionDefault
limitnumberNumber of items to fetch at once (1..100).20
offsetnumberNumber of items to skip.0

A limit outside 1..100 is rejected with 400.

#Response envelope

{
  "markets": [ /* ... */ ],
  "total": 347,
  "limit": 20,
  "offset": 0
}
FieldDescription
marketsThe data array
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

GET /v1/markets accepts sortBy and sortOrder together. For the available values, see the endpoint's spec.

#Next

Was this page helpful?