SDKs
Java
Idiomatic Java patterns for the Thunderbit Open API
Use java.net.http.HttpClient (built-in, Java 11+). For richer ergonomics — connection pooling, retries — pair with OkHttp + Jackson.
Configure
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
private static final String API = "https://openapi.thunderbit.com/openapi/v1";
private static final HttpClient CLIENT = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
private static HttpRequest.Builder request(String path) {
return HttpRequest.newBuilder()
.uri(URI.create(API + path))
.header("Authorization", "Bearer " + System.getenv("THUNDERBIT_API_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(60));
}Distill a page
String body = "{\"url\":\"https://thunderbit.com/playground\"}";
HttpResponse<String> res = CLIENT.send(
request("/distill").POST(HttpRequest.BodyPublishers.ofString(body)).build(),
HttpResponse.BodyHandlers.ofString()
);
if (res.statusCode() >= 400) throw new RuntimeException(res.body());Extract structured data
String body = """
{
"url": "https://example.com/product/iphone-15-pro",
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"price": { "type": "number" }
},
"required": ["name", "price"]
}
}
""";
HttpResponse<String> res = CLIENT.send(
request("/extract").POST(HttpRequest.BodyPublishers.ofString(body)).build(),
HttpResponse.BodyHandlers.ofString()
);Parse the response with Jackson or Gson into your domain type.
Batch + webhook
String body = """
{
"urls": ["https://example.com/page1", "https://example.com/page2"],
"webhook": {
"url": "https://your-server.com/webhook",
"secret": "%s"
}
}
""".formatted(System.getenv("WEBHOOK_SECRET"));
HttpResponse<String> res = CLIENT.send(
request("/batch/distill").POST(HttpRequest.BodyPublishers.ofString(body)).build(),
HttpResponse.BodyHandlers.ofString()
);Verify the webhook signature in your handler — see Webhooks.
An official Java SDK is in development — check back soon.