LoginSignup
0
0

More than 5 years have passed since last update.

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

Posted at

イントロダクション

マネジメントAPIであなたがアクセスできるすべてのデータをStoryblokから読み込んだり書き込んだりしてみましょう。これはStoryblokの機能を拡張するのにも使えます。例えば他のソースからデータをインポートするといったことです。

レート制限

マネジメントAPIはフリープランで3リクエスト毎秒に、その他のプランで5リクエスト毎秒にレートが制限されています。

認証(Authentication)

認証に取り掛かる最も簡単な方法は、Storyblok appを使ってOAuth2トークンを生成することです。app.storyblok.comのMy Accountへ飛び、"Generate new token"をクリックします。

OAuth2トークンを使用することで、ユーザーネームとパスワードを永続的に格納しておく必要が無くなり、アクセスをいつでも取り消すことができます。

Node.js

var axios = require('axios')

axios.get('https://api.storyblok.com/v1/spaces', {
  headers: {'Authorization': 'YOUR_AUTH_TOKEN'}
})
.then(function (response) {
  console.log(response.data)
})
.catch(function (error) {
  console.log(error.response.data)
})

Ruby

gem 'redis'

RestClient.get 'https://api.storyblok.com/v1/spaces',
    {:Authorization => 'YOUR_OAUTH_TOKEN'}

PHP

$request = new HttpRequest();
$request->setUrl('https://api.storyblok.com/v1/spaces');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'Authorization' => 'YOUR_AUTH_TOKEN'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
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