API リファレンス
API の概要
主公 は Hono フレームワークで構築された RESTful API を提供し、高い性能と型安全性を備えています。
ベース URL:http://localhost:3000/api
認証
特に記載がない限り、すべての API リクエストに認証が必要です。リクエストにセッショントークンを含めてください。
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:3000/api/spaces
エンドポイント
スペース
スペースの一覧を取得
GET /api/spaces
レスポンス:
{
"spaces": [
{
"id": "space_123",
"name": "My Workspace",
"description": "Team workspace",
"createdAt": "2024-01-15T10:30:00Z"
}
]
}
スペースを作成
POST /api/spaces
Content-Type: application/json
{
"name": "New Workspace",
"description": "Description here"
}
レスポンス:
{
"space": {
"id": "space_124",
"name": "New Workspace",
"description": "Description here",
"createdAt": "2024-01-15T11:00:00Z"
}
}
スペースを取得
GET /api/spaces/:spaceId
スペースを更新
PATCH /api/spaces/:spaceId
Content-Type: application/json
{
"name": "Updated Name",
"description": "Updated description"
}
スペースを削除
DELETE /api/spaces/:spaceId
ノード
スペース内のノード一覧を取得
GET /api/spaces/:spaceId/nodes
クエリパラメーター:
type- ノードの種類で絞り込む(document、folder など)parentId- 親ノードの ID で絞り込むlimit- 結果の件数(既定値:50)offset- ページネーションのオフセット
ノードを作成
POST /api/spaces/:spaceId/nodes
Content-Type: application/json
{
"type": "document",
"name": "Meeting Notes",
"parentId": "node_parent_123",
"content": {
"type": "doc",
"content": []
}
}
ノードを取得
GET /api/nodes/:nodeId
ノードを更新
PATCH /api/nodes/:nodeId
Content-Type: application/json
{
"name": "Updated Name",
"content": { /* 更新後のコンテンツ */ }
}
ノードを削除
DELETE /api/nodes/:nodeId
メンバー
スペースのメンバー一覧を取得
GET /api/spaces/:spaceId/members
レスポンス:
{
"members": [
{
"id": "member_123",
"userId": "user_456",
"role": "admin",
"user": {
"name": "John Doe",
"email": "john@example.com"
}
}
]
}
メンバーを追加
POST /api/spaces/:spaceId/members
Content-Type: application/json
{
"email": "newmember@example.com",
"role": "member"
}
メンバーの役割を更新
PATCH /api/spaces/:spaceId/members/:memberId
Content-Type: application/json
{
"role": "admin"
}
メンバーを削除
DELETE /api/spaces/:spaceId/members/:memberId
エラーレスポンス
すべてのエラーは次の形式を使用します。
{
"error": "Error message",
"code": "ERROR_CODE",
"details": {}
}
主なエラーコード
UNAUTHORIZED(401) - 認証情報がない、または無効FORBIDDEN(403) - 権限が不足しているNOT_FOUND(404) - リソースが見つからないVALIDATION_ERROR(400) - リクエストデータが無効INTERNAL_ERROR(500) - サーバーエラー
レート制限
API リクエストには次の制限があります。
- 認証済みユーザー:1 時間あたり 1000 リクエスト
- 未認証:1 時間あたり 100 リクエスト
レート制限のヘッダー:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640000000
Webhook
Webhook を設定すると、リアルタイムの更新を受け取れます。
POST /api/webhooks
Content-Type: application/json
{
"url": "https://your-app.com/webhook",
"events": ["space.created", "node.updated"]
}
Webhook イベント
space.createdspace.updatedspace.deletednode.creatednode.updatednode.deletedmember.addedmember.removed