Skip to content

Storyblok Java SDK for DeliveryAPI and Richtextresolver

License

Notifications You must be signed in to change notification settings

markus-gx/storyblok-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Storyblok Java SDK - 1.0

Java CI with Maven

TL;DR

This is a Java SDK/Wrapper around (yet only) the Storyblok Delivery API.

Version 1.0

  • Added Storyblok Delivery API for fetching stories.
    • Fetch a single story with a StoryblokQueryBuilder and a custom content object or without.
    • Fetch multiple stories with a StoryblokQueryBuilder and a custom content object or without.
  • Storyblok Richtext-Resolver is now marked as //Todo Refactor

What is Storyblok?

Installation

Maven

Github Packages Dependency (See: https://docs.github.com/en/packages/guides/configuring-apache-maven-for-use-with-github-packages):

<dependency>
  <groupId>io.geilehner</groupId>
  <artifactId>storyblok-java-sdk</artifactId>
  <version>1.0.3</version>
</dependency>

For those who are not yet familiar with GitHub packages you can also pull from Jitpack.

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>
 <dependency>
    <groupId>com.github.geilix10</groupId>
    <artifactId>storyblok-java-sdk</artifactId>
    <version>1.0.3</version>
</dependency>

Examples And Usage

Initialize Storyblok SDK

Storyblok client = new Storyblok("YOUR_API_KEY");

Usage

You can make use of the following methods.

client.fetchStory(String fullSlugOrIdOrUUID)

client.fetchStory(String fullSlugOrIdOrUUID, Class<T> contentType)

client.fetchStory(String fullSlugOrIdOrUUID, StoryblokQuery query)

client.fetchStory(String fullSlugOrIdOrUUID, StoryblokQuery query, Class<T> type)

client.fetchStories(StoryblokQuery query)

client.fetchStories(StoryblokQuery query, Class<T> contentType)

Examples

//Fetch a single story with a custom content object
Story<CustomStoryContent> story = client.fetchStory("home",CustomStoryContent.class);

//Or with a custom query
Story<Map<String,Object>> story = client.fetchStory("home",StoryblokQuery.StoryblokQueryBuilder.newBuilder()
.version(StoryVersion.published)
.build());

//Fetch multiple Stories
Stories<Map<String,Object>> story = client.fetchStories(StoryblokQuery.StoryblokQueryBuilder.newBuilder()
                .startsWith("h")
                .build());