Alladdin

Work in progress

Site en construction

الموقع قيد الإنشاء

Alladdin

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 page
  • cursor, cursor, an opaque string to pass as a query parameter for the next page
  • has_more, has_more, a boolean indicating if more results exist

Example

Paginate through all invoices:

javascript
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.