Java

Java SDK

Official SDK for the ScreenshotCenter API. Capture screenshots, PDFs, HTML, and video — without writing raw HTTP calls.

Installation

terminal
<!-- Maven -->
<dependency>
  <groupId>com.screenshotcenter</groupId>
  <artifactId>screenshotcenter</artifactId>
  <version>1.0.0</version>
</dependency>
Package coming soon to Maven Centralsearch.maven.org/artifact/com.screenshotcenter/screenshotcenter

Quick start

Main.java
import com.screenshotcenter.ScreenshotCenterClient;
import org.json.JSONObject;

ScreenshotCenterClient client = new ScreenshotCenterClient("your_api_key");

JSONObject shot   = client.screenshot().create("https://example.com", null);
JSONObject result = client.waitFor(shot.getLong("id"), null, null);
System.out.println(result.getString("status")); // "finished"

More examples

Geo-targeting
Map<String, String> params = new HashMap<>();
params.put("country", "fr");
params.put("lang", "fr-FR");
JSONObject shot = client.screenshot().create("https://example.com", params);
JSONObject done = client.waitFor(shot.getLong("id"), null, null);
client.screenshot().saveImage(done.getLong("id"), "/tmp/fr.png", null);
PDF generation
Map<String, String> params = new HashMap<>();
params.put("pdf", "true");
JSONObject shot = client.screenshot().create("https://example.com", params);
JSONObject done = client.waitFor(shot.getLong("id"), null, null);
client.screenshot().savePdf(done.getLong("id"), "/tmp/page.pdf");
Error handling
import com.screenshotcenter.*;

try {
    JSONObject result = client.waitFor(id, null, 60_000L);
} catch (ScreenshotFailedError e) {
    System.err.println("Failed: " + e.getReason());
} catch (TimeoutError e) {
    System.err.println("Timed out after " + e.getTimeoutMs() + "ms");
} catch (ApiError e) {
    System.err.println("API error " + e.getStatus() + ": " + e.getMessage());
}

Resources