Java
Official Java client for the Zernio API. Built on java.net.http for Java 11+. Publish to 14+ social platforms.
The official Java client for the Zernio API. Built on the JDK's native java.net.http client. Requires Java 11+.
- Coordinates:
dev.zernio:zernio-sdk - Source: github.com/zernio-dev/zernio-java
Install
The SDK is currently distributed from source. Clone the repo and install it to your local Maven repository:
git clone https://github.com/zernio-dev/zernio-java.git
cd zernio-java
mvn clean installThen add the dependency to your project:
<dependency>
<groupId>dev.zernio</groupId>
<artifactId>zernio-sdk</artifactId>
<version>1.0.4</version>
</dependency>Or with Gradle:
implementation "dev.zernio:zernio-sdk:1.0.4"Quick start
Authenticate by attaching your Bearer API key with a request interceptor:
import java.util.List;
import java.util.UUID;
import dev.zernio.ApiClient;
import dev.zernio.ApiException;
import dev.zernio.Configuration;
import dev.zernio.api.PostsApi;
import dev.zernio.model.CreatePostRequest;
import dev.zernio.model.CreatePostRequestPlatformsInner;
public class Example {
public static void main(String[] args) {
ApiClient client = Configuration.getDefaultApiClient();
String apiKey = System.getenv("ZERNIO_API_KEY");
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + apiKey));
PostsApi postsApi = new PostsApi(client);
CreatePostRequest request = new CreatePostRequest()
.content("Hello world from Zernio!")
.platforms(List.of(
new CreatePostRequestPlatformsInner().platform("twitter").accountId("acc_xxx"),
new CreatePostRequestPlatformsInner().platform("linkedin").accountId("acc_yyy")
))
.publishNow(true);
try {
// The second argument is an optional x-request-id idempotency key.
var result = postsApi.createPost(request, UUID.randomUUID());
System.out.println(result);
} catch (ApiException e) {
System.err.println("Status code: " + e.getCode());
System.err.println("Body: " + e.getResponseBody());
}
}
}Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
Passing a fresh UUID as the x-request-id makes retries safe: requests that reuse the same ID within ~5 minutes return the original post instead of double-posting.
Error handling
API failures throw dev.zernio.ApiException, which carries the HTTP status, response body, and headers:
try {
postsApi.createPost(request, null);
} catch (ApiException e) {
System.err.println("Status code: " + e.getCode());
System.err.println("Body: " + e.getResponseBody());
System.err.println("Headers: " + e.getResponseHeaders());
}See the error handling guide for the API's error codes and retry semantics.
Full reference
The SDK exposes every API namespace as a class in dev.zernio.api: PostsApi, AccountsApi, ProfilesApi, AnalyticsApi, QueueApi, MediaApi, WebhooksApi, AdsApi, PhoneNumbersApi, WhatsAppApi, WorkflowsApi, and more. Each method maps 1:1 to an API Reference operation.