Öffentliche API
Paginierung
Cursor-basierte Paginierung für Listenendpunkte der öffentlichen API
Listenendpunkte nutzen Cursor-Paginierung. Übergeben Sie den nextCursor der vorherigen Seite, bis er null ist.
Query-Parameter
| Parameter | Standard | Grenzen | Beschreibung |
|---|---|---|---|
limit | 25 | 1–100 | Seitengrösse |
cursor | — | opaque id | Fortsetzung nach dieser Item-ID |
Antwortformat
{
"data": [{ "id": "…" }],
"nextCursor": "clx…"
}Wenn keine weitere Seite folgt, ist nextCursor null.
Beispiel
# Erste Seite
curl "https://api.cowtic.com/api/v1/orders?limit=50" \
-H "X-Api-Key: YOUR_API_KEY"
# Nächste Seite
curl "https://api.cowtic.com/api/v1/orders?limit=50&cursor=ORDER_ID" \
-H "X-Api-Key: YOUR_API_KEY"async function listAllOrders(apiKey: string) {
const items = [];
let cursor: string | null = null;
do {
const url = new URL("https://api.cowtic.com/api/v1/orders");
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
headers: { "X-Api-Key": apiKey },
});
const page = (await res.json()) as {
data: Array<{ id: string }>;
nextCursor: string | null;
};
items.push(...page.data);
cursor = page.nextCursor;
} while (cursor);
return items;
}Erfinden Sie keine Cursor. Verwenden Sie immer den exakten nextCursor-Wert der vorherigen Antwort.