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.

Lists by name are in alphabetical order without regard to capitals, events by date and start time, and every page carries on exactly where the one before stopped, so no record comes twice. On the catalogue lists meta.total says how many match your filters across all pages. A limit above 100 is held at 100. Through the MCP connector a page is the size you asked for too; only a page of unusually large records comes back shorter, with the cursor that belongs to it.

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.
total optionalinteger-How many items match the filters across every page together. On the catalogue lists (events, venues, artists, organisations, genres, cities); absent where a list does not count itself.
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