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
- Ask for the list, optionally with
limit(default 25, at most 100). - Read
meta.next_cursor. When it isnull, you are done. - Otherwise ask for the same list again, with the same filters and
cursoradded, untilnext_cursorisnull.
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
| Name | Type | Default | Description |
|---|---|---|---|
request_id required | string | - | Id of this request. |
count required | integer | - | Number of items in data. |
limit required | integer | - | The page size that was applied. |
total optional | integer | - | 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 required | string | null | - | Pass as ?cursor= for the next page. Null on the last page. |
attribution optional | Attribution | - |
Fetching everything
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