### Create a new folder using Python (requests) Source: https://www.storyblok.com/docs/api/management/stories/create-and-manage-folders.md This Python example uses the requests library to create a new folder. Ensure the requests library is installed. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories" querystring = {} payload = {"story":{"is_folder":true,"name":"A new folder","parent_id":0,"slug":"a-new-folder"}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Create Component Folder with Python (requests) Source: https://www.storyblok.com/docs/api/management/component-folders/create-a-component-folder.md A Python example using the requests library to create a component folder. This snippet requires the 'requests' library to be installed. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/component_groups/" querystring = {} payload = {"component_group":{"name":"Teasers","parent_id":"123123"}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Create Release with Swift Source: https://www.storyblok.com/docs/api/management/releases/create-a-release.md Example of creating a release using Swift's URLSession. This requires proper setup of the Storyblok URLSession extension. ```swift let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN"))) var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/releases/") request.httpMethod = "POST" request.httpBody = try JSONSerialization.data(withJSONObject: [ "release": [ "branches_to_deploy": [ 123, 456, ], "name": "Summer Special", "release_at": "2025-01-01 01:01", ], ]) let (data, _) = try await storyblok.data(for: request) print(try JSONSerialization.jsonObject(with: data)) ``` -------------------------------- ### Serve Eleventy Project Source: https://www.storyblok.com/docs/guides/eleventy.md Command to start the Eleventy development server. This command should be run from the project's root directory. ```bash npx @11ty/eleventy --serve ``` -------------------------------- ### Retrieve Webhook Actions with Kotlin (Ktor) Source: https://www.storyblok.com/docs/api/management/webhooks/retrieve-webhook-actions.md This Kotlin example uses the Ktor HttpClient to get webhook actions. It demonstrates installing the Storyblok plugin and making the GET request. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.get("spaces/288868932106293/webhook_endpoints/allowed_actions") println(response.body()) ``` -------------------------------- ### Run Storyblok Migrations Source: https://www.storyblok.com/docs/libraries/storyblok-cli.md Examples for running Storyblok migrations. Assumes a space is defined in a configuration file. ```bash storyblok migrations run hero-section ``` ```bash storyblok migrations run --filter "hero-*" --dry-run ``` ```bash storyblok migrations run --publish published --query "[highlighted][in]=true" ``` -------------------------------- ### Retrieve Stories with Storyblok JS Client Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-multiple-stories.md Example using the Storyblok JS client to retrieve published stories starting with 'articles'. Ensure you have storyblok-js-client@>=7 and node@>=18 installed. ```javascript // storyblok-js-client@>=7, node@>=18 import Storyblok from "storyblok-js-client"; const storyblok = new Storyblok({ accessToken: "krcV6QGxWORpYLUWt12xKQtt", }); try { const response = await storyblok.get('cdn/stories', { "version": "published", "starts_with": "articles" }) console.log({ response }) } catch (error) { console.log(error) } ``` -------------------------------- ### Example: Generate Migration for 'hero-section' Source: https://www.storyblok.com/docs/libraries/storyblok-cli.md This example demonstrates generating a migration file for the 'hero-section' component. It assumes a space is configured. ```bash # Generate a migration for the "hero-section" component in the specified space storyblok migrations generate hero-section ``` -------------------------------- ### Retrieve Stories from 'articles' Folder (Ruby) Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/examples/retrieving-stories-from-a-folder.md This Ruby example uses the 'storyblok' gem to retrieve stories starting with 'articles/'. Ensure you have the gem installed and replace 'YOUR_TOKEN' with your actual Storyblok token. ```ruby require 'storyblok' client = Storyblok::Client.new(token: 'YOUR_TOKEN') client.stories({:params => { "starts_with" => "articles/", "version" => "draft" }}) ``` -------------------------------- ### Create Preset with Python Source: https://www.storyblok.com/docs/api/management/presets/create-a-preset.md A Python example using the 'requests' library to create a preset. Ensure you replace 'YOUR_OAUTH_TOKEN' with your personal access token. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/presets/" querystring = {} payload = {"preset":{"component_id":62,"name":"Teaser with filled headline","preset":{"headline":"This is a default value for the preset!"}}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Retrieve Story in German using Storyblok JS Client Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/examples/retrieving-stories-in-a-particular-language.md This JavaScript example uses the Storyblok JS client to get a story in German. Ensure you have installed 'storyblok-js-client' and are using Node.js v18 or higher. ```javascript // storyblok-js-client@>=7, node@>=18 import Storyblok from "storyblok-js-client"; const storyblok = new Storyblok({ accessToken: "krcV6QGxWORpYLUWt12xKQtt", }); try { const response = await storyblok.get('cdn/stories/articles/earths-symphony-navigating-wonders-challenges-blue-oasis', { "language": "de", "version": "published" }) console.log({ response }) } catch (error) { console.log(error) } ``` -------------------------------- ### Create Preset with Kotlin Source: https://www.storyblok.com/docs/api/management/presets/create-a-preset.md This Kotlin example demonstrates creating a preset using HttpClient and the Storyblok plugin. Replace 'YOUR_OAUTH_TOKEN' with your OAuth token. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.post("spaces/288868932106293/presets/") { setBody(buildJsonObject { putJsonObject("preset") { put("component_id", 62) put("name", "Teaser with filled headline") putJsonObject("preset") { put("headline", "This is a default value for the preset!") } } }) } println(response.body()) ``` -------------------------------- ### Retrieve German Story by UUID using Storyblok JS Client Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/examples/retrieving-localized-stories-by-uuid.md This JavaScript example uses the Storyblok JS client to get a story by its UUID and language. Ensure you have installed the client and are using Node.js v18 or higher. ```javascript // storyblok-js-client@>=7, node@>=18 import Storyblok from "storyblok-js-client"; const storyblok = new Storyblok({ accessToken: "krcV6QGxWORpYLUWt12xKQtt", }); try { const response = await storyblok.get('cdn/stories/660452d2-1a68-4493-b5b6-2f03b6fa722b', { "find_by": "uuid", "language": "de", "version": "published" }) console.log({ response }) } catch (error) { console.log(error) } ``` -------------------------------- ### Start Development Server Source: https://www.storyblok.com/docs/guides/angular.md Run the npm start command to launch your Angular development server. Visit the site in your browser to see the integrated Storyblok content. ```bash npm start ``` -------------------------------- ### Filter Stories by Date (gt_date) using C# (RestSharp) Source: https://www.storyblok.com/docs/api/content-delivery/v2/filter-queries/operation-gt-date.md This C# example uses the RestSharp library to make a GET request to the Storyblok API for filtering stories by date. It includes the necessary URL and request setup. ```csharp var client = new RestClient("https://api.storyblok.com/v2/cdn/stories/?filter_query%5Bscheduled%5D%5Bgt_date%5D=2023-12-31+09%3A00&token=ask9soUkv02QqbZgmZdeDAtt"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Signed URL using Swift Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example shows how to get a signed URL for an asset using Swift's URLSession. ```APIDOC ## Swift - Get Signed URL ### Description Fetches a signed URL for an asset using Swift's URLSession and Storyblok extensions. ### Method URLSession data task with modified URLRequest. ### Endpoint `assets/me` ### Query Parameters - **filename** (string) - Required - The URL of the asset. ### Request Example ```swift let storyblok = URLSession(storyblok: .cdn(accessToken: "cNGPp8cvuCfoAZB3g3eHrAtt")) var request = URLRequest(storyblok: storyblok, path: "assets/me") request.url!.append(queryItems: [ URLQueryItem(name: "filename", value: "https://a.storyblok.com/f/44203/x/5231aa9c8a/favicon.ico") ]) let (data, _) = try await storyblok.data(for: request) print(try JSONSerialization.jsonObject(with: data)) ``` ``` -------------------------------- ### Create Folder (Java) Source: https://www.storyblok.com/docs/api/management/stories/create-and-manage-folders.md This Java example demonstrates how to create a folder using the Unirest library. Replace placeholders with your actual token and IDs. ```java HttpResponse response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"story":{"content":{"content_types":["category"],"lock_subfolders_content_types":false},"is_folder":true,"name":"Categories","parent_id":0,"slug":"categories"}}) .asString(); ``` -------------------------------- ### Navigate to Project Directory Source: https://www.storyblok.com/docs/plugins/field-plugins/development.md After creating the project, change into the newly generated project directory to access its files and run commands. ```bash cd training-field/ ``` -------------------------------- ### Get Signed URL using Python (requests) Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example shows how to get a signed URL for an asset using the requests library in Python. ```APIDOC ## Python (requests) - Get Signed URL ### Description Retrieves a signed URL for an asset using the Python requests library. ### Method GET ### Endpoint `https://api.storyblok.com/v2/cdn/assets/me` ### Query Parameters - **token** (string) - Required - Your Storyblok API token. - **filename** (string) - Required - The URL-encoded filename of the asset. ### Request Example ```python import requests url = "https://api.storyblok.com/v2/cdn/assets/me" querystring = {"token":"cNGPp8cvuCfoAZB3g3eHrAtt","filename":"https://a.storyblok.com/f/44203/x/5231aa9c8a/favicon.ico"} payload = "" headers = {} response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` ``` -------------------------------- ### Get Signed URL using Java (Unirest) Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example shows how to get a signed URL for an asset using the Unirest library in Java. ```APIDOC ## Java (Unirest) - Get Signed URL ### Description Fetches a signed URL for an asset using the Unirest HTTP client in Java. ### Method GET ### Endpoint `https://api.storyblok.com/v2/cdn/assets/me` ### Query Parameters - **token** (string) - Required - Your Storyblok API token. - **filename** (string) - Required - The URL-encoded filename of the asset. ### Request Example ```java HttpResponse response = Unirest.get("https://api.storyblok.com/v2/cdn/assets/me?token=cNGPp8cvuCfoAZB3g3eHrAtt&filename=https%3A%2F%2Fa.storyblok.com%2Ff%2F44203%2Fx%2F5231aa9c8a%2Ffavicon.ico") .asString(); ``` ``` -------------------------------- ### Retrieve Component Folder with Python (requests) Source: https://www.storyblok.com/docs/api/management/component-folders/retrieve-a-single-component-folder.md A Python example using the requests library to fetch a component folder. Set up the URL, headers with your authorization token, and make the GET request. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/component_groups/4123" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Get Signed URL using Storyblok JS Client Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example shows how to use the Storyblok JavaScript client to get a signed URL for an asset. ```APIDOC ## Storyblok JS Client - Get Signed URL ### Description Uses the Storyblok JavaScript client to request a signed URL for an asset. ### Method `storyblok.get('cdn/assets/me', { "filename": "..." })` ### Parameters - **filename** (string) - Required - The URL of the asset. ### Request Example ```javascript // storyblok-js-client@>=7, node@>=18 import Storyblok from "storyblok-js-client"; const storyblok = new Storyblok({ accessToken: "krcV6QGxWORpYLUWt12xKQtt", }); try { const response = await storyblok.get('cdn/assets/me', { "filename": "https://a.storyblok.com/f/44203/x/5231aa9c8a/favicon.ico" }) console.log({ response }) } catch (error) { console.log(error) } ``` ``` -------------------------------- ### Storyblok CLI Generate Migration Examples Source: https://www.storyblok.com/docs/packages/storyblok-cli Examples of generating migration files for a 'hero-section' component, including using a custom suffix. ```bash # Generate a migration for the "hero-section" component in the specified space storyblok migrations generate hero-section # Generate a migration for the "hero-section" component in the specified space, saving with a custom suffix storyblok migrations generate hero-section --suffix dev ``` -------------------------------- ### Retrieve Statistics by Date - Kotlin Example Source: https://www.storyblok.com/docs/api/management/statistics/retrieve-statistics-by-date.md This Kotlin example uses the HttpClient with the Storyblok plugin to get statistics. Ensure you provide your OAuth token. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.get("spaces/44203/statistics/2026-03-01") println(response.body()) ``` -------------------------------- ### Start Symfony Development Server Source: https://www.storyblok.com/docs/guides/symfony.md Starts the local Symfony development server. Access your application via the provided URL. ```plaintext symfony server:start ``` -------------------------------- ### Example of Pulling Components with Storyblok CLI Source: https://www.storyblok.com/docs/libraries/storyblok-cli.md Demonstrates how to pull components from a Storyblok space using the CLI with automatic configuration detection. ```bash storyblok components pull ``` -------------------------------- ### Get Unpublished Dependencies using Python Requests Source: https://www.storyblok.com/docs/api/management/stories/get-unpublished-dependencies.md A Python example using the requests library to get unpublished dependencies. Replace YOUR_OAUTH_TOKEN with your valid token. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/unpublished_dependencies" querystring = {} payload = {"story_ids":[522672112,534980620]} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Get GitHub Account Details (Kotlin) Source: https://www.storyblok.com/docs/api/management/external-accounts/github.md This Kotlin example uses HttpClient with the Storyblok plugin to get GitHub account details. Replace YOUR_OAUTH_TOKEN with your token. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.get("v1/auth/github/me") println(response.body()) ``` -------------------------------- ### Create Workflow - Kotlin Example Source: https://www.storyblok.com/docs/api/management/workflows/create-a-workflow.md This Kotlin snippet demonstrates creating a workflow using HttpClient and the Storyblok plugin. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.post("spaces/288868932106293/workflows") { setBody(buildJsonObject { putJsonObject("workflow") { putJsonArray("content_types") { add("page") } put("name", "page") } }) } println(response.body()) ``` -------------------------------- ### Get GitHub Account Details (Java) Source: https://www.storyblok.com/docs/api/management/external-accounts/github.md This Java example uses Unirest to make a GET request for GitHub account details. Replace YOUR_OAUTH_TOKEN with your token. ```java HttpResponse response = Unirest.get("https://mapi.storyblok.com/v1/v1/auth/github/me") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString(); ``` -------------------------------- ### Activate an Experiment with Swift Source: https://www.storyblok.com/docs/api/management/experiments/activate-an-experiment.md This Swift example demonstrates activating an experiment using `URLSession` and Storyblok's URLSession extensions. It shows how to construct the request with query items and HTTP body. ```swift let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN"))) var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/experiments/176070002766742/activate") request.url!.append(queryItems: [ URLQueryItem(name: "end_date", value: "2026-08-20") ]) request.httpMethod = "PUT" request.httpBody = try JSONSerialization.data(withJSONObject: [ ]) let (data, _) = try await storyblok.data(for: request) print(try JSONSerialization.jsonObject(with: data)) ``` -------------------------------- ### Get AI Languages (Java) Source: https://www.storyblok.com/docs/api/management/ai-translate/ai-languages.md This Java example uses the Unirest library to make a GET request to the AI languages endpoint. Remember to replace YOUR_OAUTH_TOKEN. ```java HttpResponse response = Unirest.get("https://mapi.storyblok.com/v1/ai_languages") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString(); ``` -------------------------------- ### Create Preset with Java (Unirest) Source: https://www.storyblok.com/docs/api/management/presets/create-a-preset.md Example of creating a preset using Java with the Unirest library. Remember to replace 'YOUR_OAUTH_TOKEN' with your actual authorization token. ```java HttpResponse response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/presets/") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"preset":{"component_id":62,"name":"Teaser with filled headline","preset":{"headline":"This is a default value for the preset!"}}}) .asString(); ``` -------------------------------- ### Get Asset Signed URL with Java (Unirest) Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This Java example uses the Unirest library to make a GET request to the Storyblok API for a signed asset URL. ```java HttpResponse response = Unirest.get("https://api.storyblok.com/v2/cdn/assets/me?token=cNGPp8cvuCfoAZB3g3eHrAtt&filename=https%3A%2F%2Fa.storyblok.com%2Ff%2F44203%2Fx%2F5231aa9c8a%2Ffavicon.ico") .asString(); ``` -------------------------------- ### Create an Astro Project with Preview Token Source: https://www.storyblok.com/docs/libraries/storyblok-cli.md Creates a new Astro project, skips space creation, and utilizes a provided preview access token for an existing space. Ensure the token is valid. ```bash storyblok create ./my-astro-project --template astro --skip-space --token EXAMPLE_TOKEN ``` -------------------------------- ### App Provision Object Example Source: https://www.storyblok.com/docs/api/management/extensions/the-app-provision-object.md This JSON object illustrates the structure of the `app_provision` data, including public configuration, session status, slugs, IDs, names, sidebar/toolbar visibility, icons, and space-level settings. ```json { "app_provision": { "public_config": null, "session": null, "slug": "my-first-plugin", "app_id": 12345, "name": "My first plugin", "in_sidebar": true, "in_toolbar": false, "sidebar_icon": null, "enable_space_settings": true, "space_level_settings": {} }, "granted": false } ``` -------------------------------- ### Ruby Example for Retrieving a Single Link Source: https://www.storyblok.com/docs/api/content-delivery/v2/links/retrieve-single-link.md This Ruby example uses the storyblok gem to retrieve links. Ensure you have the gem installed and replace 'YOUR_TOKEN' with your actual access token. ```ruby require 'storyblok' client = Storyblok::Client.new(token: 'YOUR_TOKEN') client.links({:params => { "version" => "published", "starts_with" => "articles" }}) ``` -------------------------------- ### Create Workflow - Python Example Source: https://www.storyblok.com/docs/api/management/workflows/create-a-workflow.md Use the Python requests library to create a workflow. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/workflows" querystring = {} payload = {"workflow":{"content_types":["page"],"name":"page"}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Retrieve a Specific Discussion with Python (requests) Source: https://www.storyblok.com/docs/api/management/discussions/retrieve-a-specific-discussion.md A Python example using the 'requests' library to get a specific discussion. This code sets up the URL, headers, and makes the GET request. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/discussions/49473" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Retrieve All Asset Folders (Java) Source: https://www.storyblok.com/docs/api/management/asset-folders/retrieve-multiple-asset-folders.md This Java example shows how to fetch all asset folders using the Unirest library. Remember to replace YOUR_OAUTH_TOKEN with your authentication token. ```java HttpResponse response = Unirest.get("https://mapi.storyblok.com/v1/spaces/288868932106293/asset_folders/") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString(); ``` -------------------------------- ### Retrieve a Single Preset using Python (requests) Source: https://www.storyblok.com/docs/api/management/presets/retrieve-a-single-preset.md A Python example using the requests library to get a preset. This snippet includes setting up the URL, headers, and making the GET request. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/presets/1814" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Java Example for Retrieving an Activity Source: https://www.storyblok.com/docs/api/management/activities/retrieve-a-single-activity.md This Java example uses the Unirest library to make a GET request to retrieve a single activity from the Storyblok API. Remember to include your authorization token. ```java HttpResponse response = Unirest.get("https://mapi.storyblok.com/v1/spaces/288868932106293/activities/1234312323") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString(); ``` -------------------------------- ### Create Component Folder with Java (Unirest) Source: https://www.storyblok.com/docs/api/management/component-folders/create-a-component-folder.md Example of creating a component folder using Java with the Unirest library. Ensure you have Unirest configured and replace YOUR_OAUTH_TOKEN. ```java HttpResponse response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/component_groups/") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"component_group":{"name":"Teasers","parent_id":"123123"}}) .asString(); ``` -------------------------------- ### Example of Optional Parameters Source: https://www.storyblok.com/docs/libraries/js/app-extension-auth-helper.md Illustrates the use of optional parameters like baseUrl and endpointPrefix to customize authentication endpoint paths. ```js baseUrl: "https://your-app.com/"; endpointPrefix: "api/authenticate"; ``` -------------------------------- ### C# Example for Retrieving a Single Link Source: https://www.storyblok.com/docs/api/content-delivery/v2/links/retrieve-single-link.md This C# example utilizes the RestSharp library to execute a GET request for retrieving a single link. Make sure RestSharp is added to your project. ```csharp var client = new RestClient("https://api.storyblok.com/v2/cdn/links/:uuid?token=krcV6QGxWORpYLUWt12xKQtt&version=published&starts_with=articles"); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Import JSON Data with Python Source: https://www.storyblok.com/docs/api/management/stories/examples/export-import-json-examples.md This Python example uses the 'requests' library to send a PUT request for importing JSON data. Ensure the 'requests' library is installed (`pip install requests`). ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json" querystring = {"version":"1"} payload = {"data":"{\"a5a68c3e-876d-4d5e-b08f-e000efafe41d:feature:name\":\"Hallo! Release\",\"ffa153ea-8f63-467f-b370-65d5dd3d710f:paragraph:@richtext:richtext\":\"{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":null},\"content\":[{\"text\":\"\\\"Hark, what light through yonder editor breaks?\\\" Just our AI generating your next very epic storyline. \",\"type\":\"text\"},{\"type\":\"emoji\",\"attrs\":{\"name\":\"wink\",\"emoji\":\"😉\",\"fallbackImage\":\"https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/apple/64/1f609.png\"}},{\"text\":\" Speed up asset creation and balance gameplay, all with a few clicks. Give your small studio big-story power. #indiegamedev #ai #gamedevelopment2\",\"type\":\"text\"}]}]}",\"d31919a3-a807-4274-9820-0bf87f7ba03c:page:text\":\"Blog Posts\",\"page\":\"623949938\",\"language\":\"default\",\"url\":\"home\",\"text_nodes\":0}"} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("PUT", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Activate an Experiment with Kotlin Source: https://www.storyblok.com/docs/api/management/experiments/activate-an-experiment.md Activate an experiment using Kotlin with the Ktor `HttpClient`. This example shows how to configure the `Storyblok` plugin, set the URL with parameters, and send the request body. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.put("spaces/288868932106293/experiments/176070002766742/activate") { url { parameters.append("end_date", "2026-08-20") } setBody(buildJsonObject { }) } println(response.body()) ``` -------------------------------- ### Create Workflow - Java Example Source: https://www.storyblok.com/docs/api/management/workflows/create-a-workflow.md Example of creating a workflow using Unirest in Java. ```java HttpResponse response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/workflows") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"workflow":{"content_types":["page"],"name":"page"}}) .asString(); ``` -------------------------------- ### Retrieve One Story with Python (requests) Source: https://www.storyblok.com/docs/api/management/stories/retrieve-one-story.md This Python example uses the requests library to get a single story. Define the URL, headers including your OAuth token, and send the GET request. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/369689" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Retrieve a Single Space Role using Python (requests) Source: https://www.storyblok.com/docs/api/management/space-roles/retrieve-a-single-space-role.md This Python example uses the requests library to get a specific space role. It demonstrates setting up the URL, headers, and making the GET request. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/space_roles/18" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Create Workflow - PHP Example Source: https://www.storyblok.com/docs/api/management/workflows/create-a-workflow.md Create a workflow using the Storyblok ManagementClient in PHP. ```php $client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN'); $payload = ["workflow" => ["content_types" => ["page"],"name" => "page"]]; $client->post('spaces/288868932106293/workflows', $payload)->getBody(); ``` -------------------------------- ### Retrieve Stories with Java (Unirest) Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-multiple-stories.md Example of retrieving published stories starting with 'articles' using Java and the Unirest library. ```java HttpResponse response = Unirest.get("https://api.storyblok.com/v2/cdn/stories?token=ask9soUkv02QqbZgmZdeDAtt&version=published&starts_with=articles") .asString(); ``` -------------------------------- ### Running the Astro Development Server Source: https://www.storyblok.com/docs/guides/astro.md Command to start the Astro development server for local testing. ```bash npm run dev ``` -------------------------------- ### Complete Experiment (Kotlin) Source: https://www.storyblok.com/docs/api/management/experiments/complete-an-experiment.md Example in Kotlin using the HttpClient with the Storyblok plugin to complete an experiment. It shows how to set up the client and make the PUT request with a JSON object body. ```kotlin val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") } } val response = client.put("spaces/288868932106293/experiments/176070002766742/complete") { setBody(buildJsonObject { }) } println(response.body()) ``` -------------------------------- ### Retrieve Stories with Python (requests) Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-multiple-stories.md Python example using the 'requests' library to get published stories that begin with 'articles'. ```python import requests url = "https://api.storyblok.com/v2/cdn/stories" querystring = {"token":"ask9soUkv02QqbZgmZdeDAtt","version":"published","starts_with":"articles"} payload = "" headers = {} response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Java Example for Bulk Asset Move Source: https://www.storyblok.com/docs/api/management/assets/bulk-moving-of-assets.md This Java example uses Unirest to send a POST request to move multiple assets. Replace YOUR_OAUTH_TOKEN with your actual token. ```java HttpResponse response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/assets/bulk_update") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"asset_folder_id":299783,"ids":[15904978,15878980]}) .asString(); ``` -------------------------------- ### Retrieve a Story in German Source: https://www.storyblok.com/docs/api/content-delivery/v2/stories/examples/retrieving-stories-in-a-particular-language.md This example shows how to get the German version of a specific story by using the `language` query parameter. ```APIDOC ## GET /v2/cdn/stories/{story_id} ### Description Retrieves a specific story, localized to the specified language. ### Method GET ### Endpoint /v2/cdn/stories/{story_id} ### Query Parameters - **language** (string) - Required - The language code for the desired story version (e.g., 'de' for German). - **token** (string) - Required - Your Storyblok API token. - **version** (string) - Optional - Specifies whether to retrieve a draft or published version ('draft', 'published'). Defaults to 'draft'. ### Request Example ```shell curl "https://api.storyblok.com/v2/cdn/stories/articles/earths-symphony-navigating-wonders-challenges-blue-oasis?language=de&token=YOUR_API_TOKEN&version=published" ``` ### Response #### Success Response (200) Returns the story object in the requested language. #### Response Example ```json { "story": { "name": "Earth's Symphony: Navigating the Wonders and Challenges of Our Blue Oasis", "created_at": "2024-02-16T14:22:09.108Z", "published_at": "2024-03-21T16:48:09.206Z", "id": 444996765, "uuid": "660452d2-1a68-4493-b5b6-2f03b6fa722b", "content": { "_uid": "6bdf037c-f713-415c-a26a-8a9cfc926c85", "image": { "id": 14114772, "alt": "", "name": "", "focus": "", "title": "", "source": "", "filename": "https://a.storyblok.com/f/276232/2560x1946/ee938cf736/earth.jpg", "copyright": "", "fieldtype": "asset", "meta_data": {}, "is_private": "", "is_external_url": false }, "author": "51eed33d-855f-415c-ac0d-4404e03b89e1", "topics": ["solar-system"], "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "headline": "Die Symphonie der Erde: Die Wunder und Herausforderungen unserer blauen Oase", "component": "article" } } } ``` ``` -------------------------------- ### Get Signed URL using cURL Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example demonstrates how to fetch a signed URL for an asset using a cURL command. ```APIDOC ## GET /v2/cdn/assets/me ### Description Retrieves a signed URL for a given asset filename. ### Method GET ### Endpoint /v2/cdn/assets/me ### Query Parameters - **token** (string) - Required - Your Storyblok API token. - **filename** (string) - Required - The URL-encoded filename of the asset. ### Request Example ```shell curl "https://api.storyblok.com/v2/cdn/assets/me?token=cNGPp8cvuCfoAZB3g3eHrAtt&filename=https%3A%2F%2Fa.storyblok.com%2Ff%2F44203%2Fx%2F5231aa9c8a%2Ffavicon.ico" ``` ``` -------------------------------- ### Install @storyblok/app-extension-auth Source: https://www.storyblok.com/docs/libraries/js/app-extension-auth-helper.md Install the latest version of the @storyblok/app-extension-auth library using npm. ```bash npm install @storyblok/app-extension-auth@latest ``` -------------------------------- ### Create Release with Python Source: https://www.storyblok.com/docs/api/management/releases/create-a-release.md A Python example using the 'requests' library to create a release. Substitute 'YOUR_OAUTH_TOKEN' with your token. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/releases/" querystring = {} payload = {"release":{"branches_to_deploy":[123,456],"name":"Summer Special","release_at":"2025-01-01 01:01"}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("POST", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Clone Repository and Run Dev Server Source: https://www.storyblok.com/docs/plugins/field-plugins-legacy/local-development.md Clone the Storyblok fieldtype repository and install dependencies to start the local development server. ```bash git clone https://github.com/storyblok/storyblok-fieldtype cd storyblok-fieldtype npm install npm run dev ``` -------------------------------- ### Create Idea (Swift) Source: https://www.storyblok.com/docs/api/management/ideation-room/create-an-idea.md This Swift example demonstrates creating an idea using URLSession and the Storyblok SDK. Replace YOUR_OAUTH_TOKEN with your actual token. ```swift let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN"))) var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/ideas") request.httpMethod = "POST" request.httpBody = try JSONSerialization.data(withJSONObject: [ "idea": [ "assignee": nil, "author": [ "avatar": "avatars/67891/838dcb304c/avatar.jpg", "friendly_name": "Jon Doe", "id": 67891, "userid": "test@email.com", ], "bookmarks": [ ], "content": [ ], "deleted_at": nil, "description": "First idea", "internal_tag_ids": [ "12345", ], "internal_tags_list": [ [ "id": 12345, "name": "docs", ], ], "is_private": true, "name": "My first idea", "status": "draft", "stories": [ ], "story_ids": [ ], ], ]) let (data, _) = try await storyblok.data(for: request) print(try JSONSerialization.jsonObject(with: data)) ``` -------------------------------- ### Retrieve Field Plugins with Ruby Source: https://www.storyblok.com/docs/api/management/field-plugins/retrieve-multiple-field-plugins.md This Ruby example uses the storyblok gem to get field plugins. Replace 'YOUR_OAUTH_TOKEN' with your token. ```ruby require 'storyblok' client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN') client.get('field_types/') ``` -------------------------------- ### Fetch Organization Details with C# (RestSharp) Source: https://www.storyblok.com/docs/api/management/getting-started/organization This C# example utilizes the RestSharp library to execute a GET request for organization information. ```csharp var client = new RestClient("https://mapi.storyblok.com/v1/orgs/me"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN"); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Create Folder (Python) Source: https://www.storyblok.com/docs/api/management/stories/create-and-manage-folders.md This Python example uses the requests library to create a folder. It includes setting the correct headers and payload. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337" querystring = {} payload = {"story":{"content":{"content_types":["category"],"lock_subfolders_content_types":false},"is_folder":true,"name":"Categories","parent_id":0,"slug":"categories"}} headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("PUT", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Retrieve All Asset Folders (Python) Source: https://www.storyblok.com/docs/api/management/asset-folders/retrieve-multiple-asset-folders.md This Python example uses the requests library to get all asset folders. Replace YOUR_OAUTH_TOKEN with your token. ```python import requests url = "https://mapi.storyblok.com/v1/spaces/288868932106293/asset_folders/" querystring = {} payload = "" headers = { 'Authorization': "YOUR_OAUTH_TOKEN" } response = requests.request("GET", url, data=payload, headers=headers, params=querystring) print(response.text) ``` -------------------------------- ### Get AI Languages (Ruby) Source: https://www.storyblok.com/docs/api/management/ai-translate/ai-languages.md This Ruby example uses the storyblok gem to retrieve AI languages. Provide your oauth_token for authentication. ```ruby require 'storyblok' client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN') client.get('ai_languages') ``` -------------------------------- ### Complete Experiment with Swift Source: https://www.storyblok.com/docs/api/management/experiments/complete-an-experiment-with-a-winning-variant.md Complete an experiment using Swift's URLSession. This example demonstrates constructing the URL request, setting the HTTP method, and sending the JSON body. ```swift let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN"))) var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/experiments/176070002766742/complete_with_winner") request.url!.append(queryItems: [ URLQueryItem(name: "variant_id", value: "176070002762432") ]) request.httpMethod = "PATCH" request.httpBody = try JSONSerialization.data(withJSONObject: [ ]) let (data, _) = try await storyblok.data(for: request) print(try JSONSerialization.jsonObject(with: data)) ``` -------------------------------- ### Get Signed URL using Kotlin Source: https://www.storyblok.com/docs/api/content-delivery/v2/assets/get-signed-url.md This example demonstrates how to retrieve a signed URL for an asset using Kotlin's HttpClient. ```APIDOC ## Kotlin - Get Signed URL ### Description Uses Kotlin's HttpClient with the Storyblok plugin to obtain a signed URL for an asset. ### Method `client.get("assets/me")` with appended URL parameters. ### Endpoint `assets/me` ### Query Parameters - **filename** (string) - Required - The URL of the asset. ### Request Example ```kotlin val client = HttpClient { install(Storyblok(CDN)) { accessToken = "cNGPp8cvuCfoAZB3g3eHrAtt" } } val response = client.get("assets/me") { url { parameters.append("filename", "https://a.storyblok.com/f/44203/x/5231aa9c8a/favicon.ico") } } println(response.body()) ``` ```