Search Storyblok's Documentation
  1. Export a Story

Export a Story

Exporting a story can be done using a GET request for each story you want to export.

https://mapi.storyblok.com/v1/spaces/:space_id/stories/:story_id/export.json

Exporting stories is available exclusively on the Business plan and higher. Please refer to Storyblok's Pricing for further information.

Path Parameters

  • :space_id

    required number

    Numeric ID of a space

  • :story_id

    required number

    ID of the story

Query Parameters

  • version

    string

    Default: 1. Possible values: 1, 2.

  • lang_code

    string

    The language code for which the export should happen

  • export_lang

    boolean

    If the values of the lang_code should be exported or not

Example Request with lang_code

Request
curl "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true" \
  -X GET \
  -H "Authorization: YOUR_OAUTH_TOKEN" \
  -H "Content-Type: application/json"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.get('/spaces/233027/stories/314931981/export.json', {
  "lang_code": "pt-br",
  "export_lang": "true"
})
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');

$client->get('/spaces/233027/stories/314931981/export.json', [
  "lang_code" =>  "pt-br",
  "export_lang" =>  "true"
])->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

client.false('/spaces/233027/stories/314931981/export.json', {:params => {
  "lang_code" =>  "pt-br",
  "export_lang" =>  "true"
}})
Request
HttpResponse<String> response = Unirest.get("https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true")
  .header("Authorization", "YOUR_OAUTH_TOKEN")
  .asString();
Request
var client = new RestClient("https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true");
var request = new RestRequest(Method.GET);

request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
IRestResponse response = client.Execute(request);
Request
import Foundation

let headers = [
  "Content-Type": "application/json",
  "Authorization": "YOUR_OAUTH_TOKEN"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
request.method = "GET"
request.allHTTPHeaderFields = headers

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()
Request
import requests

url = "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json"

querystring = {"lang_code":"pt-br","export_lang":"true"}

payload = ""
headers = {
  'Content-Type': "application/json",
  'Authorization': "YOUR_OAUTH_TOKEN"
}

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)

Example Request with version=2

In version one, the page:richtext response was stringified, requiring parsing before processing. In version two, it is exported directly as a text value. This updated version also preserves the structure of blocks within rich text, including nested blocks, making it particularly beneficial for translation scenarios.

Request
curl "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true&version=2" \
  -X GET \
  -H "Authorization: YOUR_OAUTH_TOKEN" \
  -H "Content-Type: application/json"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.get('/spaces/233027/stories/314931981/export.json', {
  "lang_code": "pt-br",
  "export_lang": "true",
  "version": "2"
})
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');

$client->get('/spaces/233027/stories/314931981/export.json', [
  "lang_code" =>  "pt-br",
  "export_lang" =>  "true",
  "version" =>  "2"
])->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

client.false('/spaces/233027/stories/314931981/export.json', {:params => {
  "lang_code" =>  "pt-br",
  "export_lang" =>  "true",
  "version" =>  "2"
}})
Request
HttpResponse<String> response = Unirest.get("https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true&version=2")
  .header("Authorization", "YOUR_OAUTH_TOKEN")
  .asString();
Request
var client = new RestClient("https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true&version=2");
var request = new RestRequest(Method.GET);

request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
IRestResponse response = client.Execute(request);
Request
import Foundation

let headers = [
  "Content-Type": "application/json",
  "Authorization": "YOUR_OAUTH_TOKEN"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json?lang_code=pt-br&export_lang=true&version=2")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
request.method = "GET"
request.allHTTPHeaderFields = headers

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()
Request
import requests

url = "https://mapi.storyblok.com/v1/spaces/233027/stories/314931981/export.json"

querystring = {"lang_code":"pt-br","export_lang":"true","version":"2"}

payload = ""
headers = {
  'Content-Type': "application/json",
  'Authorization': "YOUR_OAUTH_TOKEN"
}

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
Example v2 response
{
  '59ea90a7-c548-4d96-ae11-3d4ed40a5176:dp_richtext:richtext:content/content[0].content[0].text':
    'Dummy text content',
  '59ea90a7-c548-4d96-ae11-3d4ed40a5176:dp_richtext:richtext:content/content[1].attrs.body[0].content.content[0].content[0].text':
    'This is a hint component',
  'i-19d10cb3-3884-45bf-a1c4-5f27e852d636:dp_hint:color': 'green',
  'i-19d10cb3-3884-45bf-a1c4-5f27e852d636:dp_hint:richtext:content/content[0].content[0].text':
    'This is a hint component',
  '6fae1c25-6c32-4268-8d52-173e8ca4996a:dp_page:og_title': '',
  page: '592234781',
  language: 'default',
  url: 'docs/plugins/tool-plugins',
  text_nodes: 0,
}