---
title: "Content API · Leiho"
description: "Leiho serves your content to the front end, already shaped for it. WordPress stays the single source of truth, and your repository holds code, not content."
url: https://leiho.dev/features/content-api
lang: en
updated: 2026-11-04
---
Content API

# Your whole site in one request.

Leiho serves your content to the front end, already shaped for it. WordPress stays the single source of truth, and your repository holds code, not content.

- [Try it in your browser](https://leiho.dev/try)
- [Read the docs](https://leiho.dev/docs)

```build
import { loadLeihoContent, indexLeihoContent } from 'leiho/content';

const { data } = await loadLeihoContent({ url: 'https://cms.example.com' });
const content = indexLeihoContent(data);

const home = content.byPath('/');
home.fields.hero_title;
```

304 Not Modified · GET /wp-json/leiho/v1/export

### One request per build

The export returns every published item at once, instead of one request per page.

### 304 when nothing changed

Responses carry an ETag. An unchanged build gets a 304 and downloads nothing.

### Generated types

npx leiho types writes TypeScript declarations of exactly the JSON you receive.

### Snapshot fallback

If WordPress doesn't answer, the build carries on with the last known content and says so.

### Front-end shapes

Images come with url, alt, sizes; relations with their path; rich text already rendered.

### Plugs into your caches

Object cache, page caches and CDNs are used and purged when content changes.

## Load once, read everywhere

One call in your build, then look pages up by path, type or slug.

```build
import { loadLeihoContent, indexLeihoContent } from 'leiho/content';

const { data } = await loadLeihoContent({ url: 'https://cms.example.com' });
const content = indexLeihoContent(data);

const home = content.byPath('/');
home.fields.hero_title;
```

### Endpoints

GET /wp-json/leiho/v1/export returns everything. /content filters and paginates, /content/{id} returns one item (drafts for logged-in editors), /types returns the TypeScript declarations.

### Public or restricted

Published content is public by default. Switch the API to restricted and set LEIHO_TOKEN in your build environment.

More features

- [**Visual editing**Click and type on the real page](https://leiho.dev/features/visual-editing)
- [**Collections**Your content model, with or without ACF](https://leiho.dev/features/collections)
- [**Localization**Every language, one entry](https://leiho.dev/features/localization)
- [**Publishing**Live, build hook, GitHub Actions, Coolify](https://leiho.dev/features/publishing)
- [**AI and agents**Brand voice and MCP for your agents](https://leiho.dev/features/ai)
- [**SEO and AI search**Structured data, llms.txt, Markdown](https://leiho.dev/features/ai-search)

## Edit the real site.

Free and open source. Try it on a real WordPress, in your browser.

- [Try it in your browser](https://leiho.dev/try)
- [View on GitHub](https://github.com/pixelersagency/leiho)
