Search Storyblok's Documentation
  1. Retrieving Stories with Resolved Relations

Retrieving Stories with Resolved Relations

Relations to other stories, established via Single-Option, Multi-Options, or References field, can be resolved using the resolve_relations parameter. The resolved stories are found in the rels array of the response.

Example Request and Response

The following example demonstrates how to resolve the relations of the categories and author fields.

Request
curl "https://api.storyblok.com/v2/cdn/stories?resolve_relations=article.categories,article.author" \
  -X GET \
  -H "Accept: application/json" \
  -H "Content-Type: application/json"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.get('cdn/stories', {
  "resolve_relations": "article.categories,article.author"
})
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\Client('YOUR_STORYBLOK_SPACE_ACCESS_TOKEN');

$client->getStories([
  "resolve_relations" =>  "article.categories,article.author"
])->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

client.stories({:params => {
  "resolve_relations" =>  "article.categories,article.author"
}})
Request
HttpResponse<String> response = Unirest.get("https://api.storyblok.com/v2/cdn/stories?resolve_relations=article.categories,article.author")
  .asString();
Request
var client = new RestClient("https://api.storyblok.com/v2/cdn/stories?resolve_relations=article.categories,article.author");
var request = new RestRequest(Method.GET);

IRestResponse response = client.Execute(request);
Request
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.storyblok.com/v2/cdn/stories?resolve_relations=article.categories,article.author")! 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()
Request
import requests

url = "https://api.storyblok.com/v2/cdn/stories"

querystring = {"resolve_relations":"article.categories,article.author"}

payload = ""
headers = {}

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

print(response.text)
Response
{
  "stories": [
    {
      "name": "Mars Unveiled: Exploring the Mysteries and Marvels of the Red Frontier",
      "created_at": "2024-02-16T14:30:19.768Z",
      "published_at": "2024-03-21T16:47:55.644Z",
      "id": 445002665,
      "uuid": "a2c57c06-2c5c-4819-acb7-0d9c047d16e9",
      "content": {
        "_uid": "6bdf037c-f713-415c-a26a-8a9cfc926c85",
        "image": {
          "id": 14114865,
          "alt": "",
          "name": "",
          "focus": "",
          "title": "",
          "source": "",
          "filename": "https://a.storyblok.com/f/276232/3500x2000/cd4947ece2/mars.jpg",
          "copyright": "",
          "fieldtype": "asset",
          "meta_data": {},
          "is_private": "",
          "is_external_url": false
        },
        "author": "e7307a9e-a3c5-47ad-8f6c-a1a36fe528e2",
        "topics": ["space-exploration", "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.",
        "headline": "Mars Unveiled: Exploring the Mysteries and Marvels of the Red Frontier",
        "component": "article",
        "scheduled": "2024-02-29 17:00",
        "categories": [
          "45d968b6-5790-4fbb-aa41-5781b8edde51",
          "a6af7728-eadf-4428-8cf5-343304857374",
          "d8e48716-0ecf-4059-b568-343bf54e4128"
        ],
        "highlighted": false
      },
      "slug": "mars-unveiled-exploring-mysteries-marvels-red-frontier",
      "full_slug": "articles/mars-unveiled-exploring-mysteries-marvels-red-frontier",
      "sort_by_date": null,
      "position": 0,
      "tag_list": ["Editor's Choice"],
      "is_startpage": false,
      "parent_id": 444991588,
      "meta_data": null,
      "group_id": "2e0c427d-63ed-420e-830f-bf1889da0792",
      "first_published_at": "2024-02-16T14:30:11.990Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    },
    {
      "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": "Earth's Symphony: Navigating the Wonders and Challenges of Our Blue Oasis",
        "component": "article",
        "scheduled": "2023-10-01 15:00",
        "categories": ["45d968b6-5790-4fbb-aa41-5781b8edde51", "d8e48716-0ecf-4059-b568-343bf54e4128"],
        "highlighted": false
      },
      "slug": "earths-symphony-navigating-wonders-challenges-blue-oasis",
      "full_slug": "articles/earths-symphony-navigating-wonders-challenges-blue-oasis",
      "sort_by_date": null,
      "position": 0,
      "tag_list": ["Editor's Choice", "Featured"],
      "is_startpage": false,
      "parent_id": 444991588,
      "meta_data": null,
      "group_id": "8d99d18d-5c97-42cd-a646-51e0c553f26a",
      "first_published_at": "2024-02-16T14:30:11.990Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    }
  ],
  "cv": 1711039689,
  "rels": [
    {
      "name": "Sarah Saturn",
      "created_at": "2024-02-16T14:34:46.888Z",
      "published_at": "2024-02-16T14:34:49.802Z",
      "id": 445020772,
      "uuid": "e7307a9e-a3c5-47ad-8f6c-a1a36fe528e2",
      "content": {
        "bio": "We like to say Sarah is, \"One with marketing.\" She is a guru when it comes to copy-editing, page ideation, and design. Best of all, she always executes flawlessly. In her free time, she likes to read about space, update Wiki space articles and work on her mini diorama of the Apollo Lunar Module.",
        "_uid": "e83f15e0-27e3-436c-97b9-1ea163804c8d",
        "component": "author"
      },
      "slug": "sarah-saturn",
      "full_slug": "authors/sarah-saturn",
      "sort_by_date": null,
      "position": 0,
      "tag_list": [],
      "is_startpage": false,
      "parent_id": 445020177,
      "meta_data": null,
      "group_id": "caa63bbb-87cc-4f53-bde8-5efb74ef8b97",
      "first_published_at": "2024-02-16T14:34:49.802Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    },
    {
      "name": "Jimmy Moons",
      "created_at": "2024-02-16T14:35:02.379Z",
      "published_at": "2024-02-16T14:35:04.658Z",
      "id": 445021953,
      "uuid": "51eed33d-855f-415c-ac0d-4404e03b89e1",
      "content": {
        "bio": "Jimmy is a front-end engineer who loves crafting beautiful and fast websites. His favorite technologies include Nuxt, Astro, Tailwind, and Storyblok. As a kid, Jimmy wanted to be the first man on Mars, but he discovered his love for developing. Thus, starting his journey toward his true passion.",
        "_uid": "98811439-d739-4886-a99f-fd2c9ebcf293",
        "component": "author"
      },
      "slug": "jimmy-moons",
      "full_slug": "authors/jimmy-moons",
      "sort_by_date": null,
      "position": -10,
      "tag_list": [],
      "is_startpage": false,
      "parent_id": 445020177,
      "meta_data": null,
      "group_id": "367ab023-f911-4810-b3d3-3fb0d6847ce1",
      "first_published_at": "2024-02-16T14:35:04.658Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    },
    {
      "name": "Category A",
      "created_at": "2024-02-16T14:21:28.387Z",
      "published_at": "2024-02-16T14:21:44.231Z",
      "id": 444996626,
      "uuid": "45d968b6-5790-4fbb-aa41-5781b8edde51",
      "content": {
        "_uid": "1a218a01-69b0-4482-a948-23324c1c06e2",
        "title": "Category B",
        "component": "category"
      },
      "slug": "category-a",
      "full_slug": "categories/category-a",
      "sort_by_date": null,
      "position": 0,
      "tag_list": [],
      "is_startpage": false,
      "parent_id": 444996621,
      "meta_data": null,
      "group_id": "d036028d-1d26-415f-9021-5a03359005b4",
      "first_published_at": "2024-02-16T14:21:35.503Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    },
    {
      "name": "Category B",
      "created_at": "2024-02-16T14:21:41.703Z",
      "published_at": "2024-02-16T14:21:47.299Z",
      "id": 444996629,
      "uuid": "d8e48716-0ecf-4059-b568-343bf54e4128",
      "content": {
        "_uid": "1a218a01-69b0-4482-a948-23324c1c06e2",
        "title": "Category A",
        "component": "category"
      },
      "slug": "category-b",
      "full_slug": "categories/category-b",
      "sort_by_date": null,
      "position": 0,
      "tag_list": [],
      "is_startpage": false,
      "parent_id": 444996621,
      "meta_data": null,
      "group_id": "933aae5e-458a-4ffc-973e-e9314b6a0688",
      "first_published_at": "2024-02-16T14:21:35.503Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    },
    {
      "name": "Category C",
      "created_at": "2024-02-16T14:21:55.856Z",
      "published_at": "2024-02-16T14:21:57.785Z",
      "id": 444996710,
      "uuid": "a6af7728-eadf-4428-8cf5-343304857374",
      "content": {
        "_uid": "e114cd77-363d-4368-96fc-e0be712234aa",
        "title": "Category C",
        "component": "category"
      },
      "slug": "category-c",
      "full_slug": "categories/category-c",
      "sort_by_date": null,
      "position": -10,
      "tag_list": [],
      "is_startpage": false,
      "parent_id": 444996621,
      "meta_data": null,
      "group_id": "d7d49882-9e79-42d7-9208-ad0285fce790",
      "first_published_at": "2024-02-16T14:21:57.785Z",
      "release_id": null,
      "lang": "default",
      "path": null,
      "alternates": [],
      "default_full_slug": null,
      "translated_slugs": null
    }
  ],
  "links": []
}