LoginSignup
0
0

More than 5 years have passed since last update.

Storyblokのdocs翻訳チャレンジその16!!!

Last updated at Posted at 2018-09-30

ストーリーに管理

ストーリーのリストを取得

エンドポイント

GET /v1/spaces/:space_id/stories

パラメータ

名前 説明
page ストーリーの現在のページ
contain_component コンテンツの全ての階層に対するコンポーネントによるフィルタ。
コンマ区切りの値で複数コンポーネントを指定できる。
search_term 全文検索を用いた言葉によるフィルタ

リクエスト

クエリパラメータ

page=0
contain_component=headline

cURL

curl "https://api.storyblok.com/v1/spaces/616/stories?page=0&contain_component=headline" -X GET \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODAsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.-TZDY3Ro797STmzijXpFf3HcrBkHtEFczqsrzNWrRiI" \

レスポンス

ボディー

{
  "stories": [
    {
      "name": "Test",
      "parent_id": 0,
      "created_at": "2018-07-20T08:34:52.406Z",
      "deleted_at": null,
      "group_id": "ad4f1ed1-af27-416e-a458-98ffa7bdc707",
      "sort_by_date": null,
      "updated_at": "2018-07-20T08:34:52.406Z",
      "published_at": null,
      "id": 1055,
      "uuid": "17067eef-aa84-4f9a-b36e-4318356a0b9a",
      "is_folder": false,
      "published": false,
      "slug": "test",
      "path": null,
      "full_slug": "test",
      "position": 0,
      "unpublished_changes": null,
      "is_startpage": false,
      "pinned": false,
      "publish_at": null,
      "expire_at": null
    }
  ]
}

ストーリー単位で取得

エンドポイント

GET /v1/spaces/:space_id/stories/:id

リクエスト

cURL

curl "https://api.storyblok.com/v1/spaces/615/stories/1054" -X GET \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4NzcsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.p2dO2ejrIgvFLDGG-5m6H13eOv0hRmz52z1u9-Tri8A" \

レスポンス

ボディ

{
  "story": {
    "name": "Home",
    "parent_id": 0,
    "group_id": "0748dbcf-3a72-4c32-a6ba-8aa77f0259b2",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.290Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.324Z",
    "published_at": null,
    "id": 1054,
    "uuid": "290c83e2-a7c6-45bb-aa9e-23221a637830",
    "is_folder": false,
    "content": {
      "_uid": "xyz",
      "body": [
        {
          "_uid": "a9e16ab8-887f-4001-9548-313a09daeb2a",
          "text": "test1",
          "component": "headline"
        },
        {
          "_uid": "89a3cd23-8fd1-4ddc-abfe-a6396d012d14",
          "text": "test2",
          "component": "headline"
        }
      ],
      "component": "root"
    },
    "published": false,
    "slug": "home",
    "path": null,
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

ストーリーの作成

ストーリーはデフォルトでは公開されていません。公開されたストーリーを作成したい場合はパラメータとしてpublish=1を追加してください。

エンドポイント

POST /v1/spaces/:space_id/stories

パラメータ

名前 説明
publish '1'なら、作成後直ちに公開される
story[name](必須) ストーリーの名前
story[slug](必須) APIからStoryを受け取るために使用するslug
story[content] コンテンツのJSONツリー
story[disable_fe_editor] ビジュアルエディタを無効にするかどうか
story[default_root] デフォルトのルートコンポーネント(フォルダコンポーネントの場合に必要)
story[is_folder] ストーリーがフォルダとして振る舞うかどうか
story[group_id] グループID
例えば多言語版の間でリンクさせる場合に使う
story[path] 編集者がストーリーを開くときのURLパス
story[is_startpage] ストーリーがそのフォルダのスタートページかどうか
story[parent_id] 親フォルダのID
story[sort_by_date] 日時でソート
story[meta_data] 非公開な変更としてストーリーステータスに設定されていないメタデータを追加するためのキーバリューペア
例: ユーザーレーティング
story[pinned] ツールバーにストーリーを固定する

リクエスト

cURL

curl "https://api.storyblok.com/v1/spaces/617/stories" -d '{"story":{"name":"Story 1","content":{"component":"root","body":[]},"path":"/v1/spaces/617/stories"}}' -X POST \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODMsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.N5LY4hBe9aFpJwQG0hugKWB5gGoH_phKv8LKd4lXNCU" \

レスポンス

ボディ

{
  "story": {
    "name": "Story 1",
    "parent_id": 0,
    "group_id": "67f3ffa7-2c35-4cda-b4a0-a785b309d378",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.532Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.532Z",
    "published_at": null,
    "id": 1057,
    "uuid": "67c3f2d5-68f7-40ea-9088-a1987d6fa792",
    "is_folder": false,
    "content": {
      "component": "root",
      "body": [

      ],
      "_uid": "94e61722-c18f-479a-9618-d732d6365629"
    },
    "published": false,
    "slug": "3e85af6f-0103-4142-8fd1-73e76239fd9b",
    "path": "/v1/spaces/617/stories",
    "full_slug": "3e85af6f-0103-4142-8fd1-73e76239fd9b",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

ストーリーを削除

エンドポイント

DELETE /v1/spaces/:space_id/stories/:id

リクエスト

cURL

curl "https://api.storyblok.com/v1/spaces/630/stories/1085" -d '' -X DELETE \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo5MjIsInRpbWVzdGFtcCI6MTUzMjY4MDQ5NH0.C41rwZzODXjlu_6cveHRFAJ28t-wxHtS0Vvd0U6kFAk" \

レスポンス

ボディ

{
  "story": {
    "name": "Home",
    "parent_id": 0,
    "group_id": "71d24ea9-9855-4b69-b51a-2f0f83d01776",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:54.310Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:54.310Z",
    "published_at": null,
    "id": 1085,
    "uuid": "467a0759-7682-497f-bdbe-25f913170c72",
    "is_folder": false,
    "content": {
      "_uid": "xyz",
      "body": [
        {
          "_uid": "a9e16ab8-887f-4001-9548-313a09daeb2a",
          "text": "test1",
          "component": "headline"
        },
        {
          "_uid": "89a3cd23-8fd1-4ddc-abfe-a6396d012d14",
          "text": "test2",
          "component": "headline"
        }
      ],
      "component": "root"
    },
    "published": false,
    "slug": "home",
    "path": null,
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075694"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

ストーリーのアップデート

エンドポイント

PUT /v1/spaces/:space_id/stories/:id

パラメータ

名前 説明
force_update '1'の場合、ロックされたストーリーを上書きします
publish '1'なら、作成後直ちに公開される
story[name](必須) ストーリーの名前
story[slug](必須) APIからStoryを受け取るために使用するslug
story[content] コンテンツのJSONツリー
story[disable_fe_editor] ビジュアルエディタを無効にするかどうか
story[default_root] デフォルトのルートコンポーネント(フォルダコンポーネントの場合に必要)
story[is_folder] ストーリーがフォルダとして振る舞うかどうか
story[group_id] グループID
例えば多言語版の間でリンクさせる場合に使う
story[path] 編集者がストーリーを開くときのURLパス
story[is_startpage] ストーリーがそのフォルダのスタートページかどうか
story[parent_id] 親フォルダのID
story[sort_by_date] 日時でソート
story[meta_data] 非公開な変更としてストーリーステータスに設定されていないメタデータを追加するためのキーバリューペア
例: ユーザーレーティング
story[pinned] ツールバーにストーリーを固定する

リクエスト

cURL

curl "https://api.storyblok.com/v1/spaces/618/stories/1059" -d '{"story":{"name":"Story 1","content":{"component":"root","body":[]},"path":"/v1/spaces/618/stories/1059"}}' -X PUT \
    -H "Accept: application/json" \
    -H "Content-Type: application/json"
    -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODYsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.y-gbDSuLmhgZQsJFbZEyG8krrmoNRx7oAkoUCLv_jjA" \

レスポンス

ボディ

{
  "story": {
    "name": "Story 1",
    "parent_id": 0,
    "group_id": "a93198d7-c65a-49db-b601-956b0b697420",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.639Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.679Z",
    "published_at": null,
    "id": 1059,
    "uuid": "27c08048-0331-4ae0-b639-6e258541b734",
    "is_folder": false,
    "content": {
      "component": "root",
      "body": [

      ],
      "_uid": "75752f90-07ed-4f3a-bdbe-e15a930085a9"
    },
    "published": false,
    "slug": "home",
    "path": "/v1/spaces/618/stories/1059",
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": true,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

ストーリーをJSONとしてエクスポート

リソース インフォメーション
エンドポイント https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.json
メソッド GET
ヘッダ Authorization:YOUR_MANAGEMENT_TOKEN

ストーリーをXMLとしてエクスポート

リソース インフォメーション
エンドポイント https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.xml
メソッド GET
ヘッダ Authorization:YOUR_MANAGEMENT_TOKEN

ストーリーをJSONとしてインポート

リソース インフォメーション
エンドポイント https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.json
メソッド PUT
ヘッダ Authorization:YOUR_MANAGEMENT_TOKEN
ボディ {"data":"{ \"a9e16ab8-887f-4001-9548-313a09daeb2a:headline:text\":\"translated1\", \"89a3cd23-8fd1-4ddc-abfe-a6396d012d14:headline:text\":\"translated2\", \"page\":\"285\"}"}

ストーリーをXMLとしてインポート

リソース インフォメーション
エンドポイント https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.xml
メソッド PUT
ヘッダ Authorization:YOUR_MANAGEMENT_TOKEN
ボディ {"data":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><page filename=\"home\" url=\"home\" id=\"283\"> <name>Home</name> <tags><tag id=\"a9e16ab8-887f-4001-9548-313a09daeb2a:headline:text\" type=\"STRING\"><text><![CDATA[translated1]]></text></tag><tag id=\"89a3cd23-8fd1-4ddc-abfe-a6396d012d14:headline:text\" type=\"STRING\"><text><![CDATA[translated2]]></text></tag> </tags></page>"}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0