Skip to Content
Ontwikkelaarsdocumentatie

De openbare inhoud-API aanroepen

Lees gepubliceerde inhoud met API v1, paginering, taalterugval en headless-installaties.

De openbare inhoud-API aanroepen

Gebruik de openbare API voor externe frontends of inhoudsconsumenten. Gepubliceerde items hebben geen API-sleutel nodig. Concepten en archieven zijn verborgen; wijzigingen blijven privé tot publicatie.

Identificaties en endpoints kiezen

Stel QOKIT_API_URL in op de API- of installatieoorsprong, QOKIT_PROJECT_SLUG op de projectslug en QOKIT_COLLECTION_KEY op de collectiesleutel. Deze routes gebruiken slugs en sleutels, beheerroutes gebruiken IDs.

GET /v1/projects/slug/{slug}/cms/collections/{collectionKey}/entries?locale=en&page=1&pageSize=24
GET /v1/projects/slug/{slug}/cms/collections/{collectionKey}/entries/{entrySlug}?locale=en
GET /v1/projects/slug/{slug}/runtime?locale=en

Alle pagina’s en een item lezen

Download de client volgens de instructies in De Site / CMS API gebruiken.

import { createSiteApiClient } from './sdk/client.mjs';

const api = createSiteApiClient({ baseUrl: process.env.QOKIT_API_URL });
const projectSlug = process.env.QOKIT_PROJECT_SLUG;
const collectionKey = process.env.QOKIT_COLLECTION_KEY;
const entries = [];
let page = 1;
let result;
do {
  result = await api.publicEntries(projectSlug, collectionKey, {
    locale: 'en', page, pageSize: 24
  });
  entries.push(...result.entries);
  page++;
} while (page <= result.totalPages);

if (entries.length) {
  const detail = await api.publicEntry(projectSlug, collectionKey, entries[0].slug, {
    locale: result.locale
  });
  console.log(detail.entry.title);
}
console.log(entries.length, result.locale, result.localeFallback);

Het antwoord begrijpen

Lijsten geven entries, page, pageSize, total en totalPages; details geven entry. Standaard 24, maximaal 100 items. De eerste pagina bevat niet de hele collectie.

Gebruik de teruggegeven locale voor links. localeFallback bevat requestedLocale, resolvedLocale en usedFallback. Volgorde: regionale taal, basistaal, projectstandaard, Engels. Een bovenliggende requestedLocale hangt af van de installatie.

Bekijk het contract voor search, category, brand, minPrice, maxPrice, featured en sort; werking hangt af van de collectie. Gevalideerde fieldQuery is een platformuitbreiding; onafhankelijke installaties weigeren dit met 400.

Installatie, oorsprongen en compatibiliteit

De openbare platform-runtime leest de gepubliceerde websiteversie. CMS-managed en CMS-only geven actuele openbare CMS-inhoud. Site-only bevat alleen statische HTML en bestanden, zonder content-API. CMS-only heeft geen websiterenderer. Plaats nooit een beheersleutel in frontendcode.

Bestaande platformroutes /projects/slug/{slug} blijven beschikbaar. Onafhankelijke /api/content/collections/{collectionKey}/entries blijven beschikbaar met geneste pagination-metadata. Nieuwe integraties gebruiken v1 en het OpenAPI-contract.

Verwerk 404 voor ontbrekende gepubliceerde inhoud en 400 voor ongeldige filters. Respecteer bij 429 Retry-After. Configureer toegestane frontend-oorsprongen volgens de beheergids.

Voor authenticatie, CORS, schrijven en installatieverschillen, zie De Site / CMS API gebruiken.

Was deze gids nuttig?

Laatst bijgewerkt op

Op deze pagina