Pagination
The trip list: cursors
Section titled “The trip list: cursors”GET /v1/public/products answers a page of trips with next_cursor. Send
it back as cursor, with the same filters, for the next page; it is null
on the last one. limit sets the page’s size, 1 to 100, 20 by default, and
total counts every trip that matches.
curl "https://api.stg.vacationpackagesoman.com/v1/public/products?limit=2&locale=en&cursor=WyIyMDI2LTA5LTE4VDE2OjQ1OjAwLjAwMFoiLCI4ZTlmMGExYi0yYzNkLTRlNWYtOGE2Yi03YzhkOWUwZjFhMmIiXQ" \ -H "Tp-Publishable-Key: $TP_KEY"const res = await fetch("https://api.stg.vacationpackagesoman.com/v1/public/products?limit=2&locale=en&cursor=WyIyMDI2LTA5LTE4VDE2OjQ1OjAwLjAwMFoiLCI4ZTlmMGExYi0yYzNkLTRlNWYtOGE2Yi03YzhkOWUwZjFhMmIiXQ", { headers: { "Tp-Publishable-Key": process.env.TP_KEY!, },})const answer = await res.json()Answer: 200 OK (shortened)
{ "data": [ { "id": "7d8e9f0a-1b2c-4d3e-8f4a-5b6c7d8e9f0a", "slug": "musandam-dhow-cruise-from-khasab", "title": "Musandam dhow cruise from Khasab", "city": { "slug": "khasab", "name": "Khasab" }, "region": { "slug": "musandam", "name": "Musandam" }, "country": { "slug": "om", "name": "Oman" }, "seller": { "slug": "demo", "name": "tourpingo demo" } } ], "next_cursor": null, "total": 4}A cursor is opaque: don’t build or change one.
A cursor the list didn’t give is 422 InvalidInput.
// Every trip, a page at a time.let cursor: string | null = nulldo { const page = await listTrips({ limit: 100, cursor }) render(page.data) cursor = page.next_cursor} while (cursor !== null)Search: page numbers
Section titled “Search: page numbers”GET /v1/public/search takes page (from 1) and per_page (1 to 50, 20
by default), and answers total and page.
Lists without pages
Section titled “Lists without pages”The other lists answer in one go: cities, categories, places, sellers,
pages and menus are small. A few take only a limit, such as the seller
API’s bookings (newest first, 50 by default, at most 200) and the places
search (8 by default, at most 10).