CAPI Docs
Get an API token

Pagination

POST /companies/search returns results in pages using cursor-based pagination. Rather than page numbers or offsets, each response hands you an opaque cursor that points at the next page — stable even as the underlying index changes.

Cursor-based pagination#

The search response includes a next_cursor field. To fetch the next page, send it back in the request body as cursor. When next_cursor is null, you've reached the end.

json
// Response shape
{
  "items": [ /* companies */ ],
  "total": 4213,
  "aggregations": { /* facet counts */ },
  "next_cursor": "eyJvZmZzZXQiOjI1fQ"   // null on the last page
}

Paging through results#

Loop until next_cursor is null, passing the previous cursor each time:

async function* allCompanies(filters, token) {
  let cursor = null;
  do {
    const res = await fetch("https://api.cornect.io/api/v1/companies/search", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${token}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ ...filters, cursor }),
    });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const page = await res.json();
    for (const company of page.items) yield company;
    cursor = page.next_cursor;
  } while (cursor);
}

Best practices#

  • Treat the cursor as opaque — don't parse or construct it yourself; its format may change.
  • Keep your filters identical across pages of the same scan. Changing filters mid-scan invalidates the cursor.
  • Respect the 60/min limit on search while paging — for large scans, add backoff (see Rate Limits & Backoff).
  • Use total to show progress, but page until next_cursor is null rather than computing page counts from it.
Exports vs. paging
If you need the whole result set as a file, an export is usually better than paging the search endpoint — it's built for bulk and dedups against companies you've already exported.