How do I access content via API and MCP?
5 分钟阅读中级
The Content CMS is headless — you create and manage content in the dashboard, then fetch it in your app via REST API, the Content SDK, or MCP tools.
Content REST API
Published entries are available via the Content API:
List entries
GET https://content.better-i18n.com/v1/content/{org}/{project}/models/{model}/entries
# With language filter
GET .../entries?language=tr&status=published&limit=20
Get single entry
GET https://content.better-i18n.com/v1/content/{org}/{project}/models/{model}/entries/{slug}
# With language
GET .../entries/{slug}?language=tr
Authentication
All requests require an API key in the x-api-key header:
curl -H "x-api-key: bi_pub_xxxxx" \
https://content.better-i18n.com/v1/content/acme/dashboard/models/blog-post/entries
Create content API keys from Integrations → Content CMS → Content API Keys.
Content SDK
For JavaScript/TypeScript apps, use the official SDK:
bun add @better-i18n/sdk
import { createClient } from '@better-i18n/sdk';
const content = createClient({
project: 'acme/dashboard',
apiKey: 'bi_pub_xxxxx',
});
// List entries
const posts = await content.getEntries('blog-post', {
language: 'en',
status: 'published',
limit: 20,
});
// Get single entry
const post = await content.getEntry('blog-post', 'my-first-post', {
language: 'en',
});
console.log(post.title); // "My First Post"
console.log(post.body); // Markdown body
MCP tools
AI coding agents can manage content through MCP:
| Tool | Purpose |
|---|---|
listContentEntries |
List entries with filters |
getContentEntry |
Get full entry with translations |
createContentEntry |
Create new entry |
updateContentEntry |
Update entry content or metadata |
deleteContentEntry |
Remove an entry |
publishContentEntry |
Publish a draft entry |
bulkPublishEntries |
Publish multiple entries at once |
listContentModels |
List available models |
getContentModel |
Get model with field definitions |
Example MCP usage
"List all published blog posts in Turkish"
→ listContentEntries({ modelSlug: "blog-post", status: "published", language: "tr" })
"Create a new FAQ entry about pricing"
→ createContentEntry({ modelSlug: "faq", title: "How much does it cost?", ... })
Response format
API responses include:
{
"id": "entry-uuid",
"slug": "my-first-post",
"title": "My First Post",
"body": "# My First Post\n\nContent in markdown...",
"status": "published",
"customFieldValues": {
"excerpt": "A short summary",
"reading_time": "5",
"category": "tech"
},
"availableLanguages": ["en", "tr", "fr"]
}