Java
Anyrow for Java: every endpoint, typed, on the JDK's HTTP client, for Java 17 and later.
The ai.anyrow:anyrow library has a typed method, request and response for every endpoint,
built on java.net.http.HttpClient and Jackson. Models are records. It needs Java 17 or later.
InstallLink to section
implementation("ai.anyrow:anyrow:1.0.0")Create a clientLink to section
import ai.anyrow.AnyrowClient;import java.time.Duration;AnyrowClient anyrow = AnyrowClient.builder() .baseUrl("https://api.anyrow.ai") .apiKey(System.getenv("ANYROW_API_KEY")) .timeout(Duration.ofSeconds(30)) .build();The client sends the key as Authorization: ApiKey <key>. Create one client and reuse it.
Make a callLink to section
An operation's id is its method in camel case, through one accessor per group
(extract.table.once is anyrow.extract().table().once(...)). Path parameters come first, then
the body, then a parameters object named after the method, built with a builder, which holds the
query parameters:
import ai.anyrow.models.RowListParams;var page = anyrow.row().list("proj_...", "tbl_...", RowListParams.builder().limit(50L).build());System.out.println(page.rows().size() + " rows, more: " + page.hasMore());Request bodies are records named after the operation's body (CreateProjectsTableRequest for
table.create).
ErrorsLink to section
A failed call throws an unchecked AnyrowException with the status and the
error body; each status has its own subclass:
import ai.anyrow.errors.AnyrowException;import ai.anyrow.errors.ForbiddenException;try { var table = anyrow.table().get("proj_...", "tbl_...");} catch (ForbiddenException error) { System.out.println("The key lacks tables:read");} catch (AnyrowException error) { System.out.println(error.status() + ": " + error.getMessage());}Read every rowLink to section
var rows = new ArrayList<Map<String, Object>>();String cursor = null;do { var page = anyrow.row().list("proj_...", "tbl_...", RowListParams.builder().limit(100L).cursor(cursor).build()); rows.addAll(page.rows()); cursor = page.nextCursor();} while (cursor != null);Extract a documentLink to section
var batch = anyrow.extract().table().once("proj_...", "tbl_...", Map.of("text", Files.readString(Path.of("./invoice.txt"))));System.out.println(batch.status());Stream an extractionLink to section
The stream methods return a stream of server-sent events:
anyrow.extract().table() .stream("proj_...", "tbl_...", Map.of("text", "Invoice 42 from Acme")) .forEach(event -> System.out.println(event.event() + " " + event.data()));Verify webhooksLink to section
Deliveries follow Standard Webhooks; verify them with the
standardwebhooks (opens in a new tab) Java library as the
Webhooks guide describes.