Skip to content

Conventions

Pagination

A list comes one page at a time. You page with a cursor, not an offset, so a night added halfway through never shifts a row.

How to page

  1. Ask for the list, optionally with limit (default 25, at most 100).
  2. Read meta.next_cursor. When it is null, you are done.
  3. Otherwise ask for the same list again, with the same filters and cursor added, until next_cursor is null.

Never build a cursor yourself and never change one: it is opaque, and a cursor that is not ours gets 400 invalid_request.

The meta of a list

NameTypeDefaultDescription
request_id requiredstring-Id of this request.
count requiredinteger-Number of items in data.
limit requiredinteger-The page size that was applied.
next_cursor requiredstring | null-Pass as ?cursor= for the next page. Null on the last page.
attribution optionalAttribution-

Fetching everything

javascript
async function all(path, params = {}) {
  const out = [];
  let cursor = null;
  do {
    const qs = new URLSearchParams({ ...params, limit: "100", ...(cursor ? { cursor } : {}) });
    const res = await fetch(`https://api.partyppl.nl/v1${path}?${qs}`, {
      headers: { Authorization: `Bearer ${process.env.PPL_TOKEN}` },
    });
    if (!res.ok) throw new Error((await res.json()).error.message);
    const { data, meta } = await res.json();
    out.push(...data);
    cursor = meta.next_cursor;
  } while (cursor);
  return out;
}

const amsterdam = await all("/events", { city: "Amsterdam" });

Do not fetch the whole agenda to publish it elsewhere; the terms say so. Filter on what you show and keep what you fetch.

Updated