Content API
The Content API is available on the adapter as:
$appStoryblok->contentApi
Use it to fetch and hydrate Storyblok content for the configured adapter space.
Main Methods
fetchSingleStory()
Fetches a single story by slug, id or uuid.
$appStoryblok->contentApi->fetchSingleStory("home");
fetchStories()
Fetches stories for a specific story class.
$appStoryblok->contentApi->fetchStories(PageStory::class, "pages/*");
fetchAllStories()
Fetches all stories (optionally filtered by slug pattern).
$appStoryblok->contentApi->fetchAllStories("pages/*");
getSpaceInfo()
Returns metadata for the current Storyblok space.
$appStoryblok->contentApi->getSpaceInfo();
fetchDatasourceEntries()
Fetches datasource entries from the Content API.
$appStoryblok->contentApi->fetchDatasourceEntries("countries");
fetchFoldersInPath()
Fetches folders below a slug prefix.
$appStoryblok->contentApi->fetchFoldersInPath("pages");
fetchFolderTitleMap()
Fetches a map of local folder URL to folder title.
$appStoryblok->contentApi->fetchFolderTitleMap("pages");
fetchAllLinks()
Fetches all Storyblok links.
$appStoryblok->contentApi->fetchAllLinks();
fetchSignedAssetUrl()
Fetches signed asset data for private assets.
$appStoryblok->contentApi->fetchSignedAssetUrl("https://a.storyblok.com/f/...");
Version / Release State
Most content fetch methods accept a ReleaseVersion argument as last parameter and default to ReleaseVersion::PUBLISHED.
use Torr\Storyblok\Release\ReleaseVersion;
$appStoryblok->contentApi->fetchSingleStory(
identifier: "home",
version: ReleaseVersion::DRAFT,
);
// you can also create the version from a preview flag:
ReleaseVersion::fromPreviewFlag(true);
This is supported for:
fetchSingleStory()fetchStories()fetchAllStories()fetchDatasourceEntries()fetchFoldersInPath()fetchFolderTitleMap()fetchAllLinks()