REST API リファレンス
EmDashは、コンテンツ管理、メディアアップロード、スキーマ操作のためのREST APIを /_emdash/api/ で公開しています。
APIリクエストにはBearerトークンによる認証が必要です:
Authorization: Bearer <token>トークンは管理インターフェースまたはプログラムで生成できます。
レスポンス形式
Section titled “レスポンス形式”すべてのレスポンスは一貫した形式に従います:
// Success{ "success": true, "data": { ... }}
// エラー{ "success": false, "error": { "code": "ERROR_CODE", "message": "人間が読めるメッセージ", "details": { ... } }}コンテンツエンドポイント
Section titled “コンテンツエンドポイント”コンテンツ一覧
Section titled “コンテンツ一覧”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": "はじめまして", ... }, "status": "published", "createdAt": "2025-01-24T12:00:00Z", "updatedAt": "2025-01-24T12:00:00Z" } ], "nextCursor": "eyJpZCI6..." }}コンテンツ取得
Section titled “コンテンツ取得”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" } }}コンテンツ作成
Section titled “コンテンツ作成”POST /_emdash/api/content/:collectionContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "data": { "title": "New Post", "content": [...] }, "slug": "new-post", "status": "draft"}{ "success": true, "data": { "item": { ... } }}コンテンツ更新
Section titled “コンテンツ更新”PUT /_emdash/api/content/:collection/:idContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "data": { "title": "Updated Title" }, "status": "published"}コンテンツ削除
Section titled “コンテンツ削除”DELETE /_emdash/api/content/:collection/:id{ "success": true, "data": { "success": true }}メディアエンドポイント
Section titled “メディアエンドポイント”メディア一覧
Section titled “メディア一覧”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..." }}メディア取得
Section titled “メディア取得”GET /_emdash/api/media/:idメディア作成
Section titled “メディア作成”POST /_emdash/api/mediaContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "filename": "photo.jpg", "mimeType": "image/jpeg", "size": 102400, "width": 1920, "height": 1080, "storageKey": "uploads/photo.jpg"}メディア更新
Section titled “メディア更新”PUT /_emdash/api/media/:idContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "alt": "Photo description", "caption": "Photo caption"}メディア削除
Section titled “メディア削除”DELETE /_emdash/api/media/:idメディアファイル取得
Section titled “メディアファイル取得”GET /_emdash/api/media/file/:key実際のファイルコンテンツを提供します。ローカルストレージのみ対応。
リビジョンエンドポイント
Section titled “リビジョンエンドポイント”リビジョン一覧
Section titled “リビジョン一覧”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 }}リビジョン取得
Section titled “リビジョン取得”GET /_emdash/api/revisions/:revisionIdリビジョン復元
Section titled “リビジョン復元”POST /_emdash/api/revisions/:revisionId/restoreコンテンツをこのリビジョンの状態に復元し、新しいリビジョンを作成します。
スキーマエンドポイント
Section titled “スキーマエンドポイント”コレクション一覧
Section titled “コレクション一覧”GET /_emdash/api/schema/collections{ "success": true, "data": { "items": [ { "id": "01HXK5MZSN...", "slug": "posts", "label": "Posts", "labelSingular": "Post", "supports": ["drafts", "revisions", "preview"] } ] }}コレクション取得
Section titled “コレクション取得”GET /_emdash/api/schema/collections/:slug| パラメータ | 型 | 説明 |
|---|---|---|
includeFields | boolean | フィールド定義を含める (クエリ) |
コレクション作成
Section titled “コレクション作成”POST /_emdash/api/schema/collectionsContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "slug": "products", "label": "Products", "labelSingular": "Product", "description": "Product catalog", "supports": ["drafts", "revisions"]}コレクション更新
Section titled “コレクション更新”PATCH /_emdash/api/schema/collections/:slugContent-Type: application/jsonコレクション削除
Section titled “コレクション削除”DELETE /_emdash/api/schema/collections/:slug| パラメータ | 型 | 説明 |
|---|---|---|
force | boolean | コレクションにコンテンツがあっても削除 (クエリ) |
フィールド一覧
Section titled “フィールド一覧”GET /_emdash/api/schema/collections/:slug/fieldsフィールド作成
Section titled “フィールド作成”POST /_emdash/api/schema/collections/:slug/fieldsContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "slug": "price", "label": "Price", "type": "number", "required": true, "validation": { "min": 0 }}フィールド更新
Section titled “フィールド更新”PATCH /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlugContent-Type: application/jsonフィールド削除
Section titled “フィールド削除”DELETE /_emdash/api/schema/collections/:collectionSlug/fields/:fieldSlugフィールド順序変更
Section titled “フィールド順序変更”POST /_emdash/api/schema/collections/:slug/fields/reorderContent-Type: application/jsonリクエストボディ
Section titled “リクエストボディ”{ "fieldSlugs": ["title", "content", "author", "publishedAt"]}スキーマエクスポート
Section titled “スキーマエクスポート”スキーマエクスポート (JSON)
Section titled “スキーマエクスポート (JSON)”GET /_emdash/api/schemaAccept: application/jsonスキーマエクスポート (TypeScript)
Section titled “スキーマエクスポート (TypeScript)”GET /_emdash/api/schema?format=typescriptAccept: text/typescriptすべてのコレクションのTypeScriptインターフェースを返します。
プラグインエンドポイント
Section titled “プラグインエンドポイント”プラグイン一覧
Section titled “プラグイン一覧”GET /_emdash/api/pluginsプラグイン取得
Section titled “プラグイン取得”GET /_emdash/api/plugins/:pluginIdプラグイン有効化
Section titled “プラグイン有効化”POST /_emdash/api/plugins/:pluginId/enableプラグイン無効化
Section titled “プラグイン無効化”POST /_emdash/api/plugins/:pluginId/disableエラーコード
Section titled “エラーコード”| コード | 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 | スラッグは予約済みです |
検索エンドポイント
Section titled “検索エンドポイント”グローバル検索
Section titled “グローバル検索”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": "はじめまして", "snippet": "...this is a <mark>hello</mark> <mark>world</mark> example...", "score": 0.95 } ], "nextCursor": "eyJvZmZzZXQiOjIwfQ"}検索サジェスト
Section titled “検索サジェスト”GET /_emdash/api/search/suggest?q=hel&limit=5オートコンプリート用のプレフィックス一致タイトルを返します。
検索インデックス再構築
Section titled “検索インデックス再構築”POST /_emdash/api/search/rebuildすべてまたは特定のコレクションのFTSインデックスを再構築します。
GET /_emdash/api/search/statsコレクションごとのインデックス済みドキュメント数を返します。
セクションエンドポイント
Section titled “セクションエンドポイント”セクション一覧
Section titled “セクション一覧”GET /_emdash/api/sectionsGET /_emdash/api/sections?source=themeGET /_emdash/api/sections?search=newsletterセクション取得
Section titled “セクション取得”GET /_emdash/api/sections/:slugセクション作成
Section titled “セクション作成”POST /_emdash/api/sectionsContent-Type: application/json
{ "slug": "my-section", "title": "My Section", "keywords": ["keyword1"], "content": [...]}セクション更新
Section titled “セクション更新”PUT /_emdash/api/sections/:slugセクション削除
Section titled “セクション削除”DELETE /_emdash/api/sections/:slug設定エンドポイント
Section titled “設定エンドポイント”すべての設定を取得
Section titled “すべての設定を取得”GET /_emdash/api/settingsPOST /_emdash/api/settingsContent-Type: application/json
{ "siteTitle": "私のサイト", "tagline": "すばらしいサイト", "postsPerPage": 10}メニューエンドポイント
Section titled “メニューエンドポイント”メニュー一覧
Section titled “メニュー一覧”GET /_emdash/api/menusメニュー取得
Section titled “メニュー取得”GET /_emdash/api/menus/:nameメニュー作成
Section titled “メニュー作成”POST /_emdash/api/menusContent-Type: application/json
{ "name": "footer", "label": "Footer Navigation"}メニュー更新
Section titled “メニュー更新”PUT /_emdash/api/menus/:nameメニュー削除
Section titled “メニュー削除”DELETE /_emdash/api/menus/:nameメニュー項目を追加
Section titled “メニュー項目を追加”POST /_emdash/api/menus/:name/itemsContent-Type: application/json
{ "type": "page", "referenceCollection": "pages", "referenceId": "page_about", "label": "About Us"}メニュー項目の順序変更
Section titled “メニュー項目の順序変更”POST /_emdash/api/menus/:name/reorderContent-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 } ]}タクソノミーエンドポイント
Section titled “タクソノミーエンドポイント”タクソノミー定義一覧
Section titled “タクソノミー定義一覧”GET /_emdash/api/taxonomiesタクソノミー作成
Section titled “タクソノミー作成”POST /_emdash/api/taxonomiesContent-Type: application/json
{ "name": "genre", "label": "Genres", "labelSingular": "Genre", "hierarchical": true, "collections": ["books", "movies"]}GET /_emdash/api/taxonomies/:name/termsPOST /_emdash/api/taxonomies/:name/termsContent-Type: application/json
{ "slug": "tutorials", "label": "チュートリアル", "parentId": "term_abc", "description": "ハウツーガイド"}PUT /_emdash/api/taxonomies/:name/terms/:slugDELETE /_emdash/api/taxonomies/:name/terms/:slugエントリータームを設定
Section titled “エントリータームを設定”POST /_emdash/api/content/:collection/:id/terms/:taxonomyContent-Type: application/json
{ "termIds": ["term_news", "term_featured"]}ウィジェットエリアエンドポイント
Section titled “ウィジェットエリアエンドポイント”ウィジェットエリア一覧
Section titled “ウィジェットエリア一覧”GET /_emdash/api/widget-areasウィジェットエリア取得
Section titled “ウィジェットエリア取得”GET /_emdash/api/widget-areas/:nameウィジェットエリア作成
Section titled “ウィジェットエリア作成”POST /_emdash/api/widget-areasContent-Type: application/json
{ "name": "sidebar", "label": "メインサイドバー", "description": "投稿ページに表示されます"}ウィジェットエリア削除
Section titled “ウィジェットエリア削除”DELETE /_emdash/api/widget-areas/:nameウィジェットを追加
Section titled “ウィジェットを追加”POST /_emdash/api/widget-areas/:name/widgetsContent-Type: application/json
{ "type": "content", "title": "概要", "content": [...]}ウィジェット更新
Section titled “ウィジェット更新”PUT /_emdash/api/widget-areas/:name/widgets/:idウィジェット削除
Section titled “ウィジェット削除”DELETE /_emdash/api/widget-areas/:name/widgets/:idウィジェット順序変更
Section titled “ウィジェット順序変更”POST /_emdash/api/widget-areas/:name/reorderContent-Type: application/json
{ "widgetIds": ["widget_1", "widget_2", "widget_3"]}ユーザー管理エンドポイント
Section titled “ユーザー管理エンドポイント”ユーザー一覧
Section titled “ユーザー一覧”GET /_emdash/api/admin/usersGET /_emdash/api/admin/users?role=40GET /_emdash/api/admin/users?search=johnユーザー取得
Section titled “ユーザー取得”GET /_emdash/api/admin/users/:idユーザー更新
Section titled “ユーザー更新”PATCH /_emdash/api/admin/users/:idContent-Type: application/json
{ "name": "John Doe", "role": 40}ユーザー有効化
Section titled “ユーザー有効化”POST /_emdash/api/admin/users/:id/enableユーザー無効化
Section titled “ユーザー無効化”POST /_emdash/api/admin/users/:id/disable認証エンドポイント
Section titled “認証エンドポイント”セットアップステータス
Section titled “セットアップステータス”GET /_emdash/api/setup/statusセットアップが完了し、ユーザーが存在するかどうかを返します。
パスキーログイン
Section titled “パスキーログイン”POST /_emdash/api/auth/passkey/optionsWebAuthn認証オプションを取得します。
POST /_emdash/api/auth/passkey/verifyContent-Type: application/json
{ "id": "credential-id", "rawId": "...", "response": {...}, "type": "public-key"}パスキーを検証し、セッションを作成します。
マジックリンク
Section titled “マジックリンク”POST /_emdash/api/auth/magic-link/sendContent-Type: application/json
{ "email": "user@example.com"}GET /_emdash/api/auth/magic-link/verify?token=xxxPOST /_emdash/api/auth/logout現在のユーザー
Section titled “現在のユーザー”GET /_emdash/api/auth/meユーザー招待
Section titled “ユーザー招待”POST /_emdash/api/auth/inviteContent-Type: application/json
{ "email": "newuser@example.com", "role": 30}パスキー管理
Section titled “パスキー管理”GET /_emdash/api/auth/passkeyユーザーのパスキーを一覧表示します。
POST /_emdash/api/auth/passkey/register/optionsPOST /_emdash/api/auth/passkey/register/verify新しいパスキーを登録します。
PATCH /_emdash/api/auth/passkey/:idContent-Type: application/json
{ "name": "MacBook Pro"}パスキーの名前を変更します。
DELETE /_emdash/api/auth/passkey/:idパスキーを削除します。
インポートエンドポイント
Section titled “インポートエンドポイント”WordPressエクスポートの分析
Section titled “WordPressエクスポートの分析”POST /_emdash/api/import/wordpress/analyzeContent-Type: multipart/form-data
file: <WXR file>WordPressインポートの実行
Section titled “WordPressインポートの実行”POST /_emdash/api/import/wordpress/executeContent-Type: application/json
{ "analysisId": "...", "options": { "includeMedia": true, "includeTaxonomies": true, "includeMenus": true }}APIエンドポイントは、デプロイメント構成に基づいてレート制限される場合があります。レート制限時、レスポンスには以下が含まれます:
HTTP/1.1 429 Too Many RequestsRetry-After: 60APIはブラウザリクエスト用にCORSをサポートしています。デプロイメントで許可されたオリジンを設定してください。