Branch | PHP | Code Coverage |
---|---|---|
master |
![Code Coverage][coverage-status-master] |
composer require sensiolabs-de/storyblok-api
use SensioLabs\Storyblok\Api\StoryblokClient;
$client = new StoryblokClient(
baseUri: 'https://api.storyblok.com',
token: '***********',
timeout: 10 // optional
);
// you can now request any endpoint which needs authentication
$client->request('GET', '/api/something', $options);
In your code you should type-hint to SensioLabs\Storyblok\Api\StoriesApiInterface
use SensioLabs\Storyblok\Api\StoriesApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->all(locale: 'de');
use SensioLabs\Storyblok\Api\StoriesApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
use SensioLabs\Storyblok\Api\Domain\Value\Uuid;
$uuid = new Uuid(/** ... */);
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->byUuid($uuid, locale: 'de');
use SensioLabs\Storyblok\Api\StoriesApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->bySlug('folder/slug', locale: 'de');
use SensioLabs\Storyblok\Api\StoriesApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
use SensioLabs\Storyblok\Api\Domain\Value\Id;
$id = new Id(/** ... */);
$client = new StoryblokClient(/* ... */);
$storiesApi = new StoriesApi($client);
$response = $storiesApi->byId($id, locale: 'de');
In your code you should type-hint to SensioLabs\Storyblok\Api\LinksApiInterface
use SensioLabs\Storyblok\Api\LinksApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
$client = new StoryblokClient(/* ... */);
$linksApi = new LinksApi($client);
$response = $linksApi->all();
use SensioLabs\Storyblok\Api\LinksApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
use SensioLabs\Storyblok\Api\Domain\Value\Id;
$id = new Id(/** ... */);
$client = new StoryblokClient(/* ... */);
$linksApi = new LinksApi($client);
$response = $linksApi->byParent($id);
use SensioLabs\Storyblok\Api\LinksApi;
use SensioLabs\Storyblok\Api\StoryblokClient;
$client = new StoryblokClient(/* ... */);
$linksApi = new LinksApi($client);
$response = $linksApi->roots($id);