Developers
API Guide: Page Through Results
How limit, cursor and nextCursor work for itinerary lists and Explore, with a loop that reads every page.
Every list that can be long (GET /v1/itineraries, GET /v1/accounts/{accountId}/itineraries and GET /v1/explore) returns one page at a time as { "data": [...], "nextCursor": ... }.
Steps
Ask for a page size with limit, 1 to 100. The default is 25. A value outside that range is brought into it; one that is not a number becomes 25.
Read nextCursor. When the page is full it holds a cursor; pass it back unchanged as cursor. When the page has fewer rows than limit, it is null and you have everything.
Loop until it is null.
const headers = {
Authorization: "Bearer YOUR_TOKEN",
"Travelyfe-Itinerary-Shape": "clean",
};
let cursor = null;
const all = [];
do {
const url = new URL("https://api.travelyfe.com/v1/itineraries");
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const page = await (await fetch(url, { headers })).json();
all.push(...page.data);
cursor = page.nextCursor;
} while (cursor);What You Get
All the rows, in the order the API gives them. The last page can be empty when the total is an exact multiple of limit.
If It Doesn't Work
- Repeated rows or a skipped row: itineraries changed while you were paging. Read the list again, or use
updatedSinceto fetch only what changed since your last sync. - A cursor you built yourself or edited is ignored and you get the first page again. Always use the one you were given.
429 rateLimited: slow the loop. Reads allow 120 a minute, Explore 30.
Limits
limitis 1 to 100, 25 by default.- Cursors are opaque. Never build or edit one.