Storyblok

class Storyblok(token: String, providedClient: HttpClient?, configureClient: HttpClientConfig<*>.() -> Unit?)

This class is the main API class to do all the requests on the Storyblok API.

Parameters

token

The API token used to do the API requests

providedClient

Provide a custom client implementation, not using the default

configureClient

Creates the HttpClient. Overwriting this allows to construct a custom engine, or do further adjustments to the client. Note that it is required to provide a serializer again to parse the data

Constructors

Storyblok
Link copied to clipboard
fun Storyblok(token: String)
Storyblok
Link copied to clipboard
fun Storyblok(token: String, providedClient: HttpClient? = null, configureClient: HttpClientConfig<*>.() -> Unit? = null)

Functions

fetchCurrentSpace
Link copied to clipboard
suspend fun fetchCurrentSpace(): Space?

Returns the current space object, if you're authenticated with a token.

fetchDatasourceEntries
Link copied to clipboard
suspend fun fetchDatasourceEntries(datasource: String? = null, dimension: String? = null, page: Int = 1, perPage: Int = 25, cv: Long? = null): List<Datasource>

Returns an array of datasource entry objects for the datasource and dimension defined, if authenticated using a preview or public token.

fetchDatasources
Link copied to clipboard
suspend fun fetchDatasources(page: Int = 1, perPage: Int = 25): List<Datasource>

Returns an array of datasource objects.

fetchLinks
Link copied to clipboard
suspend fun fetchLinks(startsWith: String? = null, paginated: Int? = null, page: Int = 1, perPage: Int = 25): Map<String, Link>

Returns the links object containing all links of one space. Use the version parameter and the correct token types to receive either draft and published or only published links.

fetchStories
Link copied to clipboard
suspend fun fetchStories(startsWith: String? = null, byUuids: Array<String>? = null, fallbackLang: String? = null, byUuidsOrdered: Array<String>? = null, excludingIds: IntArray? = null, excludingFields: Array<String>? = null, resolveLinks: String? = null, resolveRelations: Array<String>? = null, fromRelease: Long? = null, sortBy: Array<String>? = null, searchTerm: String? = null, filterQuery: String? = null, isStartpage: Boolean? = null, withTag: Array<String>? = null, page: Int = 1, perPage: Int = 25, cv: Long? = null): List<Story>

Returns a list of stories that are in your Storyblok space. The stories are returned in sorted order, depending on the order in your space. You can use the query parameter sort_by with any story object property and first level of your content type to order the response to your needs.

fetchStory
Link copied to clipboard
suspend fun fetchStory(key: String, findBy: String? = null, resolveLinks: String? = null, resolveRelations: String? = null, fromRelease: Long? = null, language: String? = null, fallbackLang: String? = null, cv: Long? = null): Story?

Returns a story object for the full_slug, id or uuid if authenticated using a preview or public token.

fetchTags
Link copied to clipboard
suspend fun fetchTags(startsWith: String? = null): List<Tag>

Returns an array of tag objects of one space. Use the version parameter and the correct token types to receive either draft and published or only published links.

Properties

apiEndpoint
Link copied to clipboard
var apiEndpoint: String

The endpoint to call for the requests

apiPort
Link copied to clipboard
var apiPort: Int

The port to use for the requests

apiProtocol
Link copied to clipboard
var apiProtocol: URLProtocol

The protocol to use for the requests

apiVersion
Link copied to clipboard
var apiVersion: String

The current API version to use for the requests

editMode
Link copied to clipboard
var editMode: Boolean = false

Defines if the requests shall be made in the edit mode