Skip to content

Sorting by Story Object Property

Stories can be sorted based on custom or predefined properties by employing the sort_by parameter, with field:asc or field:desc as values, allowing for ascending or descending order, respectively.

  • sort_by=name:asc: Sort by the story object property name
  • sort_by=position:desc: Sort stories in the same order as determined in the CMS
  • sort_by=first_published_at:desc: Sort by the story object property first_published_at

The following example demonstrates how to sort stories in descending order by their first published date.

curl "https://api.storyblok.com/v2/cdn/stories?token=krcV6QGxWORpYLUWt12xKQtt&sort_by=first_published_at%3Adesc"
Response
{
"stories": [
{
"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": "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
}
],
"cv": 1711108220,
"rels": [],
"links": []
}