EmDash はコンテンツ管理、メディアアップロード、スキーマ操作のための REST API を /_emdash/api/ で公開しています。
認証
API リクエストには Bearer トークンによる認証が必要です:
Authorization: Bearer <token>
管理インターフェースまたはプログラムでトークンを生成します。
レスポンス形式
すべてのレスポンスは一貫した形式に従います:
// 成功
{
"success": true,
"data": { ... }
}
// エラー
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable message",
"details": { ... }
}
}
コンテンツエンドポイント
コンテンツの一覧
GET /_emdash/api/content/:collection
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
collection | string | コレクションスラッグ(パス) |
cursor | string | ページネーションカーソル(クエリ) |
limit | number | ページあたりのアイテム数(クエリ、デフォルト: 50) |
status | string | ステータスでフィルタ(クエリ) |
orderBy | string | ソートフィールド(クエリ) |
order | string | ソート方向: asc または desc(クエリ) |
レスポンス
{
"success": true,
"data": {
"items": [
{
"id": "01HXK5MZSN...",
"type": "posts",
"slug": "hello-world",
"data": { "title": "Hello World", ... },
"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": "Hello World", ... },
"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
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
cursor | string | ページネーションカーソル |
limit | number | ページあたりのアイテム数(デフォルト: 20) |
mimeType | string | MIME タイププレフィックスでフィルタ |
レスポンス
{
"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
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
limit | number | 最大返却リビジョン数(デフォルト: 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
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
includeFields | boolean | フィールド定義を含める(クエリ) |
コレクションの作成
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
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
force | boolean | コンテンツがあっても削除(クエリ) |
フィールドの一覧
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"]
}
スキーマエクスポート
スキーマエクスポート(JSON)
GET /_emdash/api/schema
Accept: application/json
スキーマエクスポート(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_FOUND | 404 | リソースが見つからない |
VALIDATION_ERROR | 400 | 入力データが無効 |
UNAUTHORIZED | 401 | トークンが不足または無効 |
FORBIDDEN | 403 | 権限不足 |
CONTENT_LIST_ERROR | 500 | コンテンツの一覧取得に失敗 |
CONTENT_CREATE_ERROR | 500 | コンテンツの作成に失敗 |
CONTENT_UPDATE_ERROR | 500 | コンテンツの更新に失敗 |
CONTENT_DELETE_ERROR | 500 | コンテンツの削除に失敗 |
MEDIA_LIST_ERROR | 500 | メディアの一覧取得に失敗 |
MEDIA_CREATE_ERROR | 500 | メディアの作成に失敗 |
SCHEMA_ERROR | 400 | スキーマ操作に失敗 |
DUPLICATE_SLUG | 409 | スラッグが既に存在 |
RESERVED_SLUG | 400 | スラッグが予約済み |
検索エンドポイント
グローバル検索
GET /_emdash/api/search?q=hello+world
パラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
q | string | 検索クエリ(必須) |
collections | string | カンマ区切りのコレクションスラッグ |
status | string | ステータスでフィルタ(デフォルト: published) |
limit | number | 最大結果数(デフォルト: 20) |
cursor | string | ページネーションカーソル |
レスポンス
{
"results": [
{
"collection": "posts",
"id": "01HXK5MZSN...",
"slug": "hello-world",
"title": "Hello World",
"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": "My Site",
"tagline": "A great site",
"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": "Tutorials",
"parentId": "term_abc",
"description": "How-to guides"
}
タームの更新
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"]
}
ウィジェットエリアエンドポイント
ウィジェットエリアの一覧
GET /_emdash/api/widget-areas
ウィジェットエリアの取得
GET /_emdash/api/widget-areas/:name
ウィジェットエリアの作成
POST /_emdash/api/widget-areas
Content-Type: application/json
{
"name": "sidebar",
"label": "Main Sidebar",
"description": "Appears on posts"
}
ウィジェットエリアの削除
DELETE /_emdash/api/widget-areas/:name
ウィジェットの追加
POST /_emdash/api/widget-areas/:name/widgets
Content-Type: application/json
{
"type": "content",
"title": "About",
"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": "[email protected]"
}
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": "[email protected]",
"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
パスキーを削除します。
インポートエンドポイント
WordPress エクスポートの分析
POST /_emdash/api/import/wordpress/analyze
Content-Type: multipart/form-data
file: <WXR file>
WordPress インポートの実行
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
CORS
API はブラウザリクエスト用の CORS をサポートしています。デプロイメントで許可するオリジンを設定してください。