コンテンツAPI
TWPのコンテンツ管理システムで作成したコンテンツを取得・検索するAPIです。
ユースケース
- コーポレートサイトのニュース・お知らせ表示
- ブログ・メディアサイトの記事表示
- ヘッドレスCMSとしての利用
エンドポイント一覧
| メソッド | パス | 説明 |
|---|---|---|
| GET | /v1/cms/contents | コンテンツ一覧取得 |
| GET | /v1/cms/contents/{id} | コンテンツ詳細取得(ID指定) |
| GET | /v1/cms/contents/slug/{slug} | コンテンツ詳細取得(スラッグ指定) |
| GET | /v1/cms/categories | カテゴリ一覧取得 |
| GET | /v1/cms/categories/{id} | カテゴリ詳細取得 |
| POST | /v1/cms/search | コンテンツ検索 |
コンテンツ一覧取得
GET /v1/cms/contents公開済みコンテンツの一覧を取得します。
パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
category_code | string | △ | カテゴリコードで絞り込み |
category_id | string | △ | カテゴリIDで絞り込み |
tags | string | - | タグで絞り込み(カンマ区切りでAND検索) |
tag_ids | string | - | タグIDで絞り込み(カンマ区切りでAND検索) |
field_filters | string | - | カスタムフィールドで絞り込み |
sort | string | - | ソート順(例: published_at:desc) |
limit | number | - | 取得件数(1〜100、デフォルト: 20) |
cursor | string | - | ページネーションカーソル |
※ category_code または category_id のいずれかを指定することを推奨します。
リクエスト例
curl -X GET "https://your-tenant.api.tocca.systems/v1/cms/contents?category_code=news&limit=10" \
-H "X-API-Key: your_api_key"レスポンス例
{
"items": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "新サービスのお知らせ",
"slug": "new-service-announcement",
"category_id": "cat-001",
"category_code": "news",
"category_name": "ニュース",
"published_at": "2024-01-15T10:00:00Z",
"author_name": "管理者",
"tags": ["重要", "サービス"],
"summary": "新しいサービスを開始しました..."
}
],
"pagination": {
"count": 10,
"next_cursor": "eyJsYXN0X2lkIjoi...",
"has_more": true
}
}カスタムフィールドでの絞り込み
カスタムフィールドで絞り込む場合は、field_filters パラメータを使用します。
field_filters=status:active,priority:highフォーマット: フィールドID:値 をカンマ区切りで指定(最大3件)
コンテンツ詳細取得(ID指定)
GET /v1/cms/contents/{id}パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | ○ | コンテンツID |
レスポンス例
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "新サービスのお知らせ",
"slug": "new-service-announcement",
"category_id": "cat-001",
"category_code": "news",
"category_name": "ニュース",
"content": {
"body": "<p>新しいサービスを開始しました。</p>",
"summary": "新しいサービスを開始しました...",
"custom_field_1": "カスタム値"
},
"published_at": "2024-01-15T10:00:00Z",
"version": 3,
"author_name": "管理者",
"tags": ["重要", "サービス"],
"meta": {
"og_title": "新サービスのお知らせ",
"og_description": "新しいサービスを開始しました"
}
}コンテンツ詳細取得(スラッグ指定)
GET /v1/cms/contents/slug/{slug}URLフレンドリーなスラッグでコンテンツを取得します。
パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
slug | string | ○ | コンテンツのスラッグ |
カテゴリ一覧取得
GET /v1/cms/categories有効なカテゴリの一覧を取得します。
レスポンス例
{
"items": [
{
"id": "cat-001",
"code": "news",
"name": "ニュース",
"description": "会社からのお知らせ",
"sort": 1
},
{
"id": "cat-002",
"code": "blog",
"name": "ブログ",
"description": "スタッフブログ",
"sort": 2
}
]
}カテゴリ詳細取得
GET /v1/cms/categories/{id}カテゴリの詳細情報(カスタムフィールド定義を含む)を取得します。
レスポンス例
{
"id": "cat-001",
"code": "news",
"name": "ニュース",
"description": "会社からのお知らせ",
"fields": [
{
"id": "priority",
"name": "優先度",
"type": "select",
"options": ["high", "medium", "low"]
}
],
"sort": 1
}コンテンツ検索
POST /v1/cms/search全文検索でコンテンツを検索します。
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
query | string | ○ | 検索キーワード(最大500文字) |
category_id | string | - | カテゴリIDで絞り込み |
tags | string[] | - | タグで絞り込み(OR検索) |
sort | string | - | ソート順 |
from | number | - | オフセット(デフォルト: 0) |
size | number | - | 取得件数(1〜100、デフォルト: 20) |
filter | object | - | カスタムフィールドフィルター |
ソートオプション
| 値 | 説明 |
|---|---|
relevance | 関連度順(デフォルト) |
published_at:desc | 公開日時の降順(新しい順) |
published_at:asc | 公開日時の昇順(古い順) |
custom_{field}:asc | カスタムフィールドの昇順 |
custom_{field}:desc | カスタムフィールドの降順 |
カスタムフィールドフィルター
{
"query": "*",
"filter": {
"custom_status": "active",
"custom_price": {
"gte": 1000,
"lte": 5000
}
}
}使用可能な演算子:
eq: 完全一致(デフォルト)gte: 以上lte: 以下gt: 超過lt: 未満in: 複数値のいずれか
リクエスト例
curl -X POST "https://your-tenant.api.tocca.systems/v1/cms/search" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "新サービス",
"category_id": "cat-001",
"sort": "published_at:desc",
"size": 10
}'レスポンス例
{
"items": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "新サービスのお知らせ",
"slug": "new-service-announcement",
"category_id": "cat-001",
"published_at": "2024-01-15T10:00:00Z",
"author_name": "管理者",
"tags": ["重要"],
"score": 12.5,
"highlight": {
"title": ["<em>新サービス</em>のお知らせ"],
"search_text": ["...本日より<em>新サービス</em>を開始しました..."]
},
"custom_fields": {
"custom_status": "active",
"custom_price": 3000
}
}
],
"pagination": {
"total": 25,
"from": 0,
"size": 10,
"has_more": true
}
}キャッシュについて
コンテンツ一覧・詳細取得APIのレスポンスは、60秒間キャッシュされます。リアルタイム性が必要な場合は、検索APIの使用を検討してください。