Pagination
How to paginate through large result sets in the Alladdin API.
🔄 Cursor-based 📊 Up to 100/page ⏭️ has_more flag
Overview
The Alladdin API uses cursor-based pagination for list endpoints. Each response includes a cursor and a has_more flag.
How it works
When you call a list endpoint, the response includes:
items, items, the array of results for the current pagecursor, cursor, an opaque string to pass as a query parameter for the next pagehas_more, has_more, a boolean indicating if more results exist
Example
Paginate through all invoices:
let cursor = null;
let allInvoices = [];
do {
const url = new URL("https://api.alladdin.com/api/v2/invoices");
url.searchParams.set("limit", "50");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
const data = await res.json();
allInvoices.push(...data.items);
cursor = data.cursor;
} while (cursor);
console.log(`Fetched ${allInvoices.length} invoices`);Page size
Use the limit query parameter to control page size. Default is 25, maximum is 100.
