Java SDK

Official Java SDK for Anakin (anakin.io)

Official Java SDK for the Anakin API. Wraps every documented endpoint with a single synchronous call, internal polling, and a typed exception hierarchy. Zero HTTP dependencies — uses java.net.http.HttpClient from the JDK.

StatusAlpha (v0.1.x)
LanguageJava 17+
Artifactio.github.anakin-inc:anakin-sdk:0.1.0 on Maven Central
Sourcegithub.com/Anakin-Inc/anakin-java
LicenseApache 2.0

Install

Gradle:

dependencies {
    implementation 'io.github.anakin-inc:anakin-sdk:0.1.0'
}

Maven:

<dependency>
    <groupId>io.github.anakin-inc</groupId>
    <artifactId>anakin-sdk</artifactId>
    <version>0.1.0</version>
</dependency>

Requires Java 17+.

Quickstart

import io.anakin.sdk.Anakin;
import io.anakin.sdk.types.Document;

public class Demo {
    public static void main(String[] args) {
        Anakin client = Anakin.builder()
                .apiKey("ak-...")  // or set ANAKIN_API_KEY
                .build();

        // Scrape a single URL — returns the final result, no polling required
        Document doc = client.scrape("https://example.com");
        System.out.println(doc.markdown);

        // Discover URLs on a site
        var sitemap = client.map("https://example.com");
        System.out.println(sitemap.links);
    }
}

What's in v0.1

MethodReturns
client.scrape(url) / client.scrape(url, opts)Document
client.map(url) / client.map(url, opts)MapResult
client.crawl(url) / client.crawl(url, opts)CrawlResult
client.search(query) / client.search(query, opts)SearchResult (synchronous API)
client.agenticSearch(prompt) / client.agenticSearch(prompt, opts)AgenticSearchResult
client.wire(actionId, params)WireResult (run a Wire action)
client.sessions().list / create / save / update / deleteBrowser session CRUD
Countries.supported()Map<String, String> (bundled, no network call)

Configuration

Anakin client = Anakin.builder()
        .apiKey("ak-...")                              // or ANAKIN_API_KEY env var
        .baseURL("https://api.anakin.io/v1")
        .timeout(Duration.ofSeconds(60))               // per-request HTTP timeout
        .maxRetries(4)                                 // retries on 429 / 5xx
        .pollInterval(Duration.ofSeconds(1))           // initial polling delay
        .pollMaxInterval(Duration.ofSeconds(10))       // cap on exponential backoff
        .pollTimeout(Duration.ofMinutes(5))            // total wait before JobTimeoutException
        .build();

Errors

Every error thrown by the SDK is a typed subclass of AnakinException:

try {
    Document doc = client.scrape("https://example.com");
} catch (InsufficientCreditsException e) {
    System.out.printf("out of credits: balance=%d, needed=%d%n", e.getBalance(), e.getRequired());
} catch (AuthenticationException e) {
    System.out.println("invalid API key — get a fresh one at anakin.io/dashboard");
} catch (RateLimitException e) {
    System.out.printf("rate limited; retry after %s%n", e.getRetryAfter());
} catch (JobFailedException e) {
    System.out.printf("job failed: %s%n", e.getReason());
} catch (AnakinException e) {
    System.out.printf("unknown error: %s%n", e.getMessage());
}

The exception hierarchy:

TypeWhen
AuthenticationException401 — invalid or missing API key
InsufficientCreditsException402 — out of credits (getBalance(), getRequired())
InvalidRequestException400 — validation failure
RateLimitException429 — after retry budget exhausted (getRetryAfter())
JobFailedExceptionPolled job came back with status="failed" (getReason())
JobTimeoutExceptionPolling budget exhausted before terminal status
ServerException5xx — after retries exhausted
NetworkExceptionDNS / connect / read-timeout
AnakinExceptionBase type; everything above extends it

Stability

v0.1.x is alpha. The public API may change between minor versions until v1.0. Pin a specific version in production:

implementation 'io.github.anakin-inc:anakin-sdk:0.1.0'

Raise issues on GitHub.