Skip to content

Pagination

Walk long survey and response lists with an opaque cursor.

List endpoints return one page at a time together with a cursor for the next one. Cursors are opaque strings: read them from the response, pass them back unchanged, and never build one yourself.

How it works

  • limit sets the page size. It defaults to 25 and is capped at 100; a larger or invalid value is clamped rather than rejected.
  • nextCursor in the response points at the following page. Pass it as the cursor query parameter on your next call.
  • nextCursor is null on the last page. That is the only reliable end signal - a short page does not mean there is no more data.

Walk every page

Reading every survey in a workspace
javascript
async function listAllSurveys(apiKey) {
  const surveys = [];
  let cursor = null;

  do {
    const url = new URL("https://www.asqiro.com/api/v1/surveys");
    url.searchParams.set("limit", "100");
    if (cursor) url.searchParams.set("cursor", cursor);

    const response = await fetch(url, {
      headers: { authorization: `Bearer ${apiKey}` },
    });
    if (!response.ok) throw new Error(`Asqiro API returned ${response.status}`);

    const page = await response.json();
    surveys.push(...page.data);
    cursor = page.nextCursor;
  } while (cursor);

  return surveys;
}
Note Prefer the largest page size your integration can process. Fewer, larger pages cost fewer requests against your rate limit than many small ones.