Misar IO Docs

Java SDK

Install and use the MisarBlog Java SDK

Installation

Add to pom.xml:

<dependency>
    <groupId>io.misar</groupId>
    <artifactId>misarblog-java</artifactId>
    <version>1.0.0</version>
</dependency>

Quick Start

import io.misar.blog.MisarBlogClient;
import io.misar.blog.models.*;

public class Main {
    public static void main(String[] args) throws Exception {
        MisarBlogClient client = MisarBlogClient.builder()
            .apiKey(System.getenv("MISARBLOG_API_KEY"))
            .build();

        PostList posts = client.posts().list("johndoe", null).get();
        posts.getData().forEach(p -> System.out.println(p.getTitle() + " — " + p.getSlug()));
        client.close();
    }
}

Generate an Embed URL

String url = client.embed().url("johndoe", EmbedOptions.builder().theme("dark").build());
System.out.println(url);

Available Methods

| Method | Description | |--------|-------------| | client.posts().list(username, params) | List posts — returns CompletableFuture<PostList> | | client.posts().get(username, slug) | Get a single post by slug | | client.embed().url(username, options) | Generate an embed URL | | client.auth().refreshToken(token) | Refresh a session token | | client.webhooks().list() | List webhook endpoints | | client.webhooks().create(request) | Register a webhook | | client.webhooks().delete(id) | Delete a webhook | | client.close() | Close the HTTP client |

Error Handling

import io.misar.blog.exceptions.*;

try {
    PostList posts = client.posts().list("johndoe", null).get();
} catch (ExecutionException e) {
    if (e.getCause() instanceof MisarBlogApiException api) {
        System.out.println("API error " + api.getStatusCode() + ": " + api.getMessage());
    }
}