Pagination
Lists are read a page at a time with a cursor, never with page numbers.
Every list endpoint takes two query parameters and answers with the same shape:
| Parameter | Default | What it does |
|---|---|---|
limit | 25 | How many items a page holds, from 1 to 100. |
cursor | none | Where to continue from: the nextCursor of the previous page. |
{
"items": [],
"nextCursor": "0192f0c1-7a3e-7c51-9d2e-4b7f0a1c2d3e"
}nextCursor is null on the last page. There are no page numbers and no total count, so a list stays correct while items are added during the read.
Reading every page
async function allLeads(): Promise<unknown[]> {
const leads: unknown[] = []
let cursor: string | null = null
do {
const url = new URL("https://api.leadup.group/v1/leads")
url.searchParams.set("limit", "100")
if (cursor) {
url.searchParams.set("cursor", cursor)
}
const response = await fetch(url, { headers: { Authorization: `Bearer ${process.env.LEADUP_API_KEY}` } })
const page = await response.json()
leads.push(...page.items)
cursor = page.nextCursor
} while (cursor)
return leads
}Filters such as stage stay the same on every page; only the cursor changes.
Was this page helpful?