Pluma
Docs index
docs/frameworks/fetch.md View markdown →

Plain fetch

For any language or framework: the Delivery API is a GET with your key. No SDK.

const res = await fetch(
  `https://pluma.so/api/v1/spaces/${process.env.PLUMA_SPACE}/entries?content_type=event&order=fields.startsAt&rich_text=html`,
  { headers: { Authorization: `Bearer ${process.env.PLUMA_DELIVERY_KEY}` } }
);
if (!res.ok) throw new Error((await res.json()).error.message);
const { items } = await res.json();
for (const event of items) console.log(event.fields.title, event.fields.startsAt);
  • The key goes on the server or in the build, never in code that runs in the browser: PLUMA_DELIVERY_KEY as an environment variable.
  • rich_text=html gives you long text already as HTML; markdown if your site converts it; without the parameter, the JSON blocks.
  • References and images in the same response: include=1 brings them in includes.Entry and includes.Asset. See Delivery API.
  • Pagination: up to 1000 per request with limit; the rest with skip. total says how many there are.
  • Cache: with a delivery key, responses come with an ETag. Send If-None-Match and, if nothing changed, you get a 304 with no body.
  • Errors: always { "error": { "code", "message", "fix", "doc_url" } }. See Errors.