Warning: It's currently not working with US endpoints.
Storyblok API library client for python.
This library is generated by alpaca
Make sure you have pip installed
$ pip install storyblok
Works with [ 2.6 / 2.7 / 3.2 / 3.3 ]
import storyblok
# Then we instantiate a client (as shown below)
client = storyblok.Client()
# If you need to send options
client = storyblok.Client({}, client_options)
The following options are available while instantiating a client:
- base: Base url for the api
- api_version: Default version of the api (to be used in url)
- user_agent: Default user-agent for all requests
- headers: Default headers for all requests
- request_type: Default format of the request body
All the callbacks provided to an api call will recieve the response as shown below
response = client.klass('args').method('args', method_options)
response.code
# >>> 200
response.headers
# >>> {'content-type': 'application/json; charset=utf-8'}
When the response sent by server is json, it is decoded into a dict
response.body
# >>> {"story": {"name":"story_name"}}
The following options are available while calling a method of an api:
- api_version: Version of the api (to be used in url)
- headers: Headers for the request
- query: Query parameters for the url
- body: Body of the request
- request_type: Format of the request body
Set request_type in options to modify the body accordingly
When the value is set to json, JSON encode the body.
body = {'story': {'name':"story_name"}}
# >>> '{"story": {"name":"story_name"}}'
Returns your current space name, published version and domain
spaces = client.spaces()
This endpoint is mostly useful for client side apps. The response contains space.version which you can use to call the story api and get the most recent published version. (https://www.storyblok.com/docs/Delivery-Api/spaces)
The following arguments are required:
- token: Public token for published or private token for draft version
response = spaces.me("your_access_token", options)
Returns stories api instance
stories = client.stories()
Returns a list of Stories (https://www.storyblok.com/docs/Delivery-Api/get-a-story#get-a-list-of-stories)
The following arguments are required:
- token: Public token for published or private token for draft version
response = stories.list("your_access_token", "draft", "1", "25", "posts", "1527067945", options)
Returns a single story by id (https://www.storyblok.com/docs/Delivery-Api/get-a-story#get-a-story-by-id)
The following arguments are required:
- token: Public token for published or private token for draft version
response = stories.single("your_access_token", "draft", "41252", options)
Returns tags api instance
tags = client.tags()
Returns a list of tags (https://www.storyblok.com/docs/Delivery-Api/Tags)
The following arguments are required:
- token: Public token for published or private token for draft version
response = tags.list("your_access_token", "de", options)
Returns links api instance
links = client.links()
Returns a list of links (https://www.storyblok.com/docs/Delivery-Api/Links)
The following arguments are required:
- token: Public token for published or private token for draft version
response = links.list("your_access_token", "draft", "de", options)
Returns a single link by id (https://www.storyblok.com/docs/Delivery-Api/Links#get-a-single-link)
The following arguments are required:
- token: Public token for published or private token for draft version
- id: Uuid of the link
response = links.single("your_access_token", "148ee49a-ad81-4aff-b3d5-a2b4b6739e65", options)
Returns tags api instance
datasource_entries = client.datasource_entries()
Returns a list of tags (https://www.storyblok.com/docs/Delivery-Api/Tags)
The following arguments are required:
- token: Public token for published or private token for draft version
response = datasource_entries.list("your_access_token", "labels", "de-at", options)
Here is a list of Contributors
MIT
Report here.