Authentication & SDKs

To allow calls to the Storyblok content delivery API you need to identify yourself with a token. This token can be generated in the Storyblok dashboard at app.storyblok.com.

There are three kinds of tokens

  • Private: This token allows you to access the draft and published version of your content
  • Public: Only allows access to the published version of your content
  • Theme: Only allows access to Cloud Rendering Service template upload

APIs

There are following REST-APIs available at the endpoint api.storyblok.com/v1/cdn.

  • Stories, For receiving the content entries
  • Tags, For receiving tags (ex. building a tagcloud)
  • Links, For receiving the mappings of the story links
  • Datasource_entries, For receiving datasources (key value pairs)

The endpoint is made for highspeed delivery and therefore the content is cached in a CDN. If you want to receive the uncached version of your content you need to provide a version parameter in the URL. This parameter is cache_version and usually has a timestamp (The SDKs automatically ups the version timestamp).

SDKs

Development can be made easier with the use of an SDK. The following SDKs are currently available, with more to be released soon:

<script src="//app.storyblok.com/f/storyblok-latest.js"></script>
<script>
  storyblok.init({
    accessToken: 'miQeEopSce7bklQFVbBozQtt' // Your private token
  })

  // Get the content of the current page
  storyblok.get({slug: 'home', version: 'draft'}, function(data) {
    console.log(data.story)
  })

  // Get multiple content entries from a folder called "news"
  storyblok.getAll({starts_with: 'story', version: 'draft'}, function(data) {
    console.log(data.stories)
  })
</script>
var StoryblokClient = require('storyblok-node-client');

var Storyblok = new StoryblokClient({
  privateToken: '{{private_token}}' // Your private token
});

// Get the content of the current page
Storyblok
  .get('stories/home', {
    version: 'draft'
  })
  .then((response) => {
    console.log(response);
  });

// Get multiple content entries from a folder called "news"
Storyblok
  .get('stories', {
    starts_with: 'news'
    version: 'draft'
  })
  .then((response) => {
    console.log(response);
  });
client = new Storyblok::Client(token: '{{private_token}}') # Your private token

# Get the content of the current page
p client.story('home')

# Get multiple content entries from a folder called "news"
p client.stories({
  :starts_with => 'news'
})

# More on https://github.com/storyblok/storyblok-ruby
require 'vendor/autoload.php';

$client = new \Storyblok\Client('{{private_token}}'); // Your private token{%- raw -%}

// Get the content of the current page
$client->getStoryBySlug('home');
$data = $client->getBody();

// Get multiple content entries from a folder called "news"
$client->getStories(
  array(
    'starts_with' => 'news'
  )
);
$data = $client->getStoryContent();{% endraw %}

# More on https://github.com/storyblok/php-client

Documentation