Paging
A list that can be long, such as fixtures, comes back one page at a time:
{ "items": [ ... ], "nextCursor": "eyJ2IjoxLCJza2lwIjo1MCwiZiI6..." }
nextCursor is null on the last page. There is no total count.
Parameters
| Parameter | Meaning |
|---|---|
limit | Items per page, 1 to 100. Default 50. Outside that range is 400 invalid_request. |
cursor | Pass the previous response's nextCursor, exactly as given. |
To get the next page, send the same filters with cursor set:
# page 1
curl "https://api.lovebowls.co.uk/v1/clubs/CLUB_ID/fixtures?kind=match&limit=20" -H "X-Api-Key: $LB_KEY"
# page 2: the same filters, plus the cursor from page 1
curl "https://api.lovebowls.co.uk/v1/clubs/CLUB_ID/fixtures?kind=match&limit=20&cursor=CURSOR_FROM_PAGE_1" \
-H "X-Api-Key: $LB_KEY"
Rules for cursors
- The cursor is opaque. Do not decode it or build one: its contents can change.
- It is bound to the club and to the filters it was made for. Change
from,to,competition,teamorkindand the answer is400 invalid_cursor. - It can stop working after the API is updated. On
invalid_cursor, drop the cursor and start again from the first page. - Items are in a fixed order (oldest first), so paging with the same filters visits each fixture once. A fixture added or removed between two requests can shift the pages, so treat a long walk as a snapshot taken a moment ago, not as a transaction.
Walking every page
With the SDK, iterateFixtures does it for you. It takes the same filters as listFixtures, with limit
as the page size and no cursor, and fetches pages as you read:
import { LovebowlsClient } from "@lovebowls/api";
const lb = new LovebowlsClient({ apiKey: process.env.LB_KEY });
for await (const fixture of lb.iterateFixtures("CLUB_ID", { kind: "match", limit: 50 })) {
console.log(fixture.start, fixture.opponent);
}
Or by hand, with listFixtures:
let cursor;
do {
const page = await lb.listFixtures("CLUB_ID", { kind: "match", cursor });
for (const fixture of page.items) console.log(fixture.start, fixture.opponent);
cursor = page.nextCursor ?? undefined;
} while (cursor);
Each page is one request against your rate limit. A season of fixtures is a handful of
pages at most; use a larger limit rather than many small pages.
Lists that are not paged
listCompetitions returns every competition in one response ({ "items": [...] }, no nextCursor): a club
has tens, not thousands.