Authentication
API requests can be authenticated by providing a valid API access token. API access tokens can be managed in the settings of each Storyblok space. Two different types of tokens can be generated:
- Public: Grants access to published content entries:
version=published
- Preview: Grants access to draft and published content entries:
version=draft
andversion=published
Public and preview tokens are read-only and do not allow you or others to write or delete entries in a Storyblok space. The public token can safely be used in client-side code. All tokens can be revoked at any point in time. You can also create multiple tokens of the same type for specific use cases. When using content staging, it is possible to create dedicated preview and public tokens for each staging environment.
For more detailed information on generating an access token for your space, please refer to the article on generating access tokens.
There are different endpoints for the API in different regions.
Related Resources
Examples
curl "https://api.storyblok.com/v2/cdn/stories?token=wANpEQEsMYGOwLxwXQ76Ggtt" \
-X GET \
-H "Accept: application/json" \
-H "Content-Type: application/json"
// 1. Import the Storyblok Client
import StoryblokClient from "storyblok-js-client";
// 2. Initialize the Client with the token
const Storyblok = new StoryblokClient({
accessToken: "wANpEQEsMYGOwLxwXQ76Ggtt",
region: "us", // Region in which the space was created
// Possible values: "ap", "eu", "us", "ca", "cn" (Default: "eu")
});
// 3. Retrieve stories
Storyblok.get('cdn/stories', {
version: 'published',
});
$client = new \Storyblok\Client("wANpEQEsMYGOwLxwXQ76Ggtt");
$client->getStories()->getBody();
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
client.stories()
HttpResponse<String> response = Unirest.get("https://api.storyblok.com/v2/cdn/stories?token=wANpEQEsMYGOwLxwXQ76Ggtt")
.asString();
var client = new RestClient("https://api.storyblok.com/v2/cdn/stories?token=wANpEQEsMYGOwLxwXQ76Ggtt");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.storyblok.com/v2/cdn/stories?token=wANpEQEsMYGOwLxwXQ76Ggtt")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
request.method = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
import requests
url = "https://api.storyblok.com/v2/cdn/stories"
querystring = {"token":"wANpEQEsMYGOwLxwXQ76Ggtt"}
payload = ""
headers = {}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)