コンテンツにスキップ

REST API リファレンス

EmDashは、コンテンツ管理、メディアアップロード、スキーマ操作のためのREST APIを /_emdash/api/ で公開しています。

APIリクエストにはBearerトークンによる認証が必要です:

Authorization: Bearer <token>

トークンは管理インターフェースまたはプログラムで生成できます。

すべてのレスポンスは一貫した形式に従います:

// Success
{
"success": true,
"data": { ... }
}
// エラー
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "人間が読めるメッセージ",
"details": { ... }
}
}
GET /_emdash/api/content/:collection
パラメータ型説明
collectionstringコレクションスラッグ (パス)
cursorstringページネーションカーソル (クエリ)
limitnumberページあたりのアイテム数 (クエリ, デフォルト: 50)
statusstringステータスによるフィルタ (クエリ)
orderBystringソート対象フィールド (クエリ)
orderstringソート方向: asc または desc (クエリ)
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"type": "posts",
"slug": "hello-world",
"data": { "title": "はじめまして", ... },
"status": "published",
"createdAt": "2025-01-24T12:00:00Z",
"updatedAt": "2025-01-24T12:00:00Z"
}
],
"nextCursor": "eyJpZCI6..."
}
}
GET /_emdash/api/content/:collection/:id
{
"success": true,
"data": {
"item": {
"id": "01HXK5MZSN...",
"type": "posts",
"slug": "hello-world",
"data": { "title": "はじめまして", ... },
"status": "published",
"createdAt": "2025-01-24T12:00:00Z",
"updatedAt": "2025-01-24T12:00:00Z"
}
}
}
POST /_emdash/api/content/:collection
Content-Type: application/json
{
"data": {
"title": "New Post",
"content": [...]
},
"slug": "new-post",
"status": "draft"
}
{
"success": true,
"data": {
"item": { ... }
}
}
PUT /_emdash/api/content/:collection/:id
Content-Type: application/json
{
"data": {
"title": "Updated Title"
},
"status": "published"
}
DELETE /_emdash/api/content/:collection/:id
{
"success": true,
"data": {
"success": true
}
}
GET /_emdash/api/media
パラメータ型説明
cursorstringページネーションカーソル
limitnumberページあたりのアイテム数 (デフォルト: 20)
mimeTypestringMIMEタイププレフィックスによるフィルタ
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"filename": "photo.jpg",
"mimeType": "image/jpeg",
"size": 102400,
"width": 1920,
"height": 1080,
"url": "https://cdn.example.com/photo.jpg",
"createdAt": "2025-01-24T12:00:00Z"
}
],
"nextCursor": "eyJpZCI6..."
}
}
GET /_emdash/api/media/:id
POST /_emdash/api/media
Content-Type: application/json
{
"filename": "photo.jpg",
"mimeType": "image/jpeg",
"size": 102400,
"width": 1920,
"height": 1080,
"storageKey": "uploads/photo.jpg"
}
PUT /_emdash/api/media/:id
Content-Type: application/json
{
"alt": "Photo description",
"caption": "Photo caption"
}
DELETE /_emdash/api/media/:id
GET /_emdash/api/media/file/:key

実際のファイルコンテンツを提供します。ローカルストレージのみ対応。

GET /_emdash/api/content/:collection/:entryId/revisions
パラメータ型説明
limitnumber返却する最大リビジョン数 (デフォルト: 50)
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"collection": "posts",
"entryId": "01HXK5MZSN...",
"data": { ... },
"createdAt": "2025-01-24T12:00:00Z"
}
],
"total": 5
}
}
GET /_emdash/api/revisions/:revisionId
POST /_emdash/api/revisions/:revisionId/restore

コンテンツをこのリビジョンの状態に復元し、新しいリビジョンを作成します。

GET /_emdash/api/schema/collections
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"slug": "posts",
"label": "Posts",
"labelSingular": "Post",
"supports": ["drafts", "revisions", "preview"]
}
]
}
}
GET /_emdash/api/schema/collections/:slug
パラメータ型説明
includeFieldsbooleanフィールド定義を含める (クエリ)
POST /_emdash/api/schema/collections
Content-Type: application/json
{
"slug": "products",
"label": "Products",
"labelSingular": "Product",
"description": "Product catalog",
"supports": ["drafts", "revisions"]
}
PATCH /_emdash/api/schema/collections/:slug
Content-Type: application/json
DELETE /_emdash/api/schema/collections/:slug
パラメータ型説明
forcebooleanコレクションにコンテンツがあっても削除 (クエリ)
GET /_emdash/api/schema/collections/:slug/fields
POST /_emdash/api/schema/collections/:slug/fields
Content-Type: application/json
{
"slug": "price",
"label": "Price",
"type": "number",
"required": true,
"validation": {
"min": 0
}
}
PATCH /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlug
Content-Type: application/json
DELETE /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlug
POST /_emdash/api/schema/collections/:slug/fields/reorder
Content-Type: application/json
{
"fieldSlugs": ["title", "content", "author", "publishedAt"]
}
GET /_emdash/api/schema
Accept: application/json

スキーマエクスポート (TypeScript)

Section titled “スキーマエクスポート (TypeScript)”
GET /_emdash/api/schema?format=typescript
Accept: text/typescript

すべてのコレクションのTypeScriptインターフェースを返します。

GET /_emdash/api/plugins
GET /_emdash/api/plugins/:pluginId
POST /_emdash/api/plugins/:pluginId/enable
POST /_emdash/api/plugins/:pluginId/disable
コードHTTPステータス説明
NOT_FOUND404リソースが見つかりません
VALIDATION_ERROR400無効な入力データ
UNAUTHORIZED401トークンがないか無効
FORBIDDEN403権限が不足しています
CONTENT_LIST_ERROR500コンテンツ一覧の取得に失敗
CONTENT_CREATE_ERROR500コンテンツ作成に失敗
CONTENT_UPDATE_ERROR500コンテンツ更新に失敗
CONTENT_DELETE_ERROR500コンテンツ削除に失敗
MEDIA_LIST_ERROR500メディア一覧の取得に失敗
MEDIA_CREATE_ERROR500メディア作成に失敗
SCHEMA_ERROR400スキーマ操作に失敗
DUPLICATE_SLUG409スラッグが既に存在します
RESERVED_SLUG400スラッグは予約済みです
GET /_emdash/api/search?q=hello+world
パラメータ型説明
qstring検索クエリ (必須)
collectionsstringカンマ区切りのコレクションスラッグ
statusstringステータスによるフィルタ (デフォルト: published)
limitnumber最大結果数 (デフォルト: 20)
cursorstringページネーションカーソル
{
"results": [
{
"collection": "posts",
"id": "01HXK5MZSN...",
"slug": "hello-world",
"title": "はじめまして",
"snippet": "...this is a <mark>hello</mark>
<mark>world</mark>
example...",
"score": 0.95
}
],
"nextCursor": "eyJvZmZzZXQiOjIwfQ"
}
GET /_emdash/api/search/suggest?q=hel&limit=5

オートコンプリート用のプレフィックス一致タイトルを返します。

POST /_emdash/api/search/rebuild

すべてまたは特定のコレクションのFTSインデックスを再構築します。

GET /_emdash/api/search/stats

コレクションごとのインデックス済みドキュメント数を返します。

GET /_emdash/api/sections
GET /_emdash/api/sections?source=theme
GET /_emdash/api/sections?search=newsletter
GET /_emdash/api/sections/:slug
POST /_emdash/api/sections
Content-Type: application/json
{
"slug": "my-section",
"title": "My Section",
"keywords": ["keyword1"],
"content": [...]
}
PUT /_emdash/api/sections/:slug
DELETE /_emdash/api/sections/:slug
GET /_emdash/api/settings
POST /_emdash/api/settings
Content-Type: application/json
{
"siteTitle": "私のサイト",
"tagline": "すばらしいサイト",
"postsPerPage": 10
}
GET /_emdash/api/menus
GET /_emdash/api/menus/:name
POST /_emdash/api/menus
Content-Type: application/json
{
"name": "footer",
"label": "Footer Navigation"
}
PUT /_emdash/api/menus/:name
DELETE /_emdash/api/menus/:name
POST /_emdash/api/menus/:name/items
Content-Type: application/json
{
"type": "page",
"referenceCollection": "pages",
"referenceId": "page_about",
"label": "About Us"
}
POST /_emdash/api/menus/:name/reorder
Content-Type: application/json
{
"items": [
{ "id": "item_1", "parentId": null, "sortOrder": 0 },
{ "id": "item_2", "parentId": null, "sortOrder": 1 },
{ "id": "item_3", "parentId": "item_2", "sortOrder": 0 }
]
}
GET /_emdash/api/taxonomies
POST /_emdash/api/taxonomies
Content-Type: application/json
{
"name": "genre",
"label": "Genres",
"labelSingular": "Genre",
"hierarchical": true,
"collections": ["books", "movies"]
}
GET /_emdash/api/taxonomies/:name/terms
POST /_emdash/api/taxonomies/:name/terms
Content-Type: application/json
{
"slug": "tutorials",
"label": "チュートリアル",
"parentId": "term_abc",
"description": "ハウツーガイド"
}
PUT /_emdash/api/taxonomies/:name/terms/:slug
DELETE /_emdash/api/taxonomies/:name/terms/:slug
POST /_emdash/api/content/:collection/:id/terms/:taxonomy
Content-Type: application/json
{
"termIds": ["term_news", "term_featured"]
}

ウィジェットエリアエンドポイント

Section titled “ウィジェットエリアエンドポイント”
GET /_emdash/api/widget-areas
GET /_emdash/api/widget-areas/:name
POST /_emdash/api/widget-areas
Content-Type: application/json
{
"name": "sidebar",
"label": "メインサイドバー",
"description": "投稿ページに表示されます"
}
DELETE /_emdash/api/widget-areas/:name
POST /_emdash/api/widget-areas/:name/widgets
Content-Type: application/json
{
"type": "content",
"title": "概要",
"content": [...]
}
PUT /_emdash/api/widget-areas/:name/widgets/:id
DELETE /_emdash/api/widget-areas/:name/widgets/:id
POST /_emdash/api/widget-areas/:name/reorder
Content-Type: application/json
{
"widgetIds": ["widget_1", "widget_2", "widget_3"]
}
GET /_emdash/api/admin/users
GET /_emdash/api/admin/users?role=40
GET /_emdash/api/admin/users?search=john
GET /_emdash/api/admin/users/:id
PATCH /_emdash/api/admin/users/:id
Content-Type: application/json
{
"name": "John Doe",
"role": 40
}
POST /_emdash/api/admin/users/:id/enable
POST /_emdash/api/admin/users/:id/disable
GET /_emdash/api/setup/status

セットアップが完了し、ユーザーが存在するかどうかを返します。

POST /_emdash/api/auth/passkey/options

WebAuthn認証オプションを取得します。

POST /_emdash/api/auth/passkey/verify
Content-Type: application/json
{
"id": "credential-id",
"rawId": "...",
"response": {...},
"type": "public-key"
}

パスキーを検証し、セッションを作成します。

POST /_emdash/api/auth/magic-link/send
Content-Type: application/json
{
"email": "user@example.com"
}
GET /_emdash/api/auth/magic-link/verify?token=xxx
POST /_emdash/api/auth/logout
GET /_emdash/api/auth/me
POST /_emdash/api/auth/invite
Content-Type: application/json
{
"email": "newuser@example.com",
"role": 30
}
GET /_emdash/api/auth/passkey

ユーザーのパスキーを一覧表示します。

POST /_emdash/api/auth/passkey/register/options
POST /_emdash/api/auth/passkey/register/verify

新しいパスキーを登録します。

PATCH /_emdash/api/auth/passkey/:id
Content-Type: application/json
{
"name": "MacBook Pro"
}

パスキーの名前を変更します。

DELETE /_emdash/api/auth/passkey/:id

パスキーを削除します。

POST /_emdash/api/import/wordpress/analyze
Content-Type: multipart/form-data
file: <WXR file>
POST /_emdash/api/import/wordpress/execute
Content-Type: application/json
{
"analysisId": "...",
"options": {
"includeMedia": true,
"includeTaxonomies": true,
"includeMenus": true
}
}

APIエンドポイントは、デプロイメント構成に基づいてレート制限される場合があります。レート制限時、レスポンスには以下が含まれます:

HTTP/1.1 429 Too Many Requests
Retry-After: 60

APIはブラウザリクエスト用にCORSをサポートしています。デプロイメントで許可されたオリジンを設定してください。