Skip to main content
The Kotlin client is built for coroutines. Every call is a suspend function, every paginated endpoint is a Flow, and every model is a kotlinx.serialization data class. It covers the statutes, session law, watch, board, credit and pricing operations of the US Data API; the SDKs overview lists the operations without a method yet. It targets JVM 11 and newer, and depends on kotlinx-serialization-json and kotlinx-coroutines-core. Transport is the JDK java.net.http.HttpClient, so there is no HTTP engine to choose. For the options shared by all SDKs, see the SDKs overview.
Preview. Not yet published to Maven Central, so build locally and use publishToMavenLocal until the first release.

Install

Build it locally from the kotlin/ directory of the repository.
The intended dependency does not resolve today.
Source: Vaquill-AI/vaquill-sdks, kotlin/ on GitHub.

Quickstart

Create one client and share it. It is thread safe, and safe to call from many coroutines at once. Call close() (or use use {}) to release its threads.

Configuration

Per-call overrides go in RequestOptions(timeout, maxRetries, idempotencyKey, headers), the last parameter of every method. client.withOptions { ... } makes a copy that shares the transport and the spend total. Authorization and Idempotency-Key cannot be overridden by default or per-call headers. timeout is the total time for one HTTP attempt, from sending the request until the whole response body has been read. Each retry gets a fresh budget. Connecting has its own fixed 5 s limit. This is stricter than the Python SDK for very large bodies, so raise timeout for them or use Duration.ZERO. The logger receives every line after API key redaction, and idempotency keys are logged by their first 8 characters only. Read the status, request id and credits of a call with withResponse.
If the block makes several requests, the last response is reported.

Errors

Everything the SDK throws extends VaquillException.
The class is chosen by the error code first, then by status, so an unknown future code still gives the status class.

Retries and idempotency

The SDKs retry 408, 429 and 5xx responses, plus a 409 only for idempotency_in_progress. Connection errors and timeouts are retried when it is safe to do so. The default is 2 retries, and setting the retry limit to 0 turns retries off. Backoff starts at 0.5 seconds, doubles to an 8 second cap and is scaled down by 0 to 25 percent jitter. The wait comes from the retry-after-ms header first, then Retry-After (seconds or an HTTP date), then the body’s retryAfterSeconds. A wait above 120 seconds is not slept: the error is raised at once. Never retried: a 402 insufficient_credits, daily_cap_exceeded, any other 4xx, and anything the server marks retryable: false. Kotlin specifics:
  • 501 is not retried, and the codes the server marks retryable are retried.
  • Connect failures never reached the server, so they are always retried.
  • Other transport failures are ambiguous. They are retried only for GET and HEAD, or when the call carries an idempotency key.
  • A 5xx on a charged call is not retried unless the call has an idempotency key, because it may already have been billed.
Each charged call sends one generated Idempotency-Key, reused on every retry of that call. When the server honours the key it replays the stored response instead of charging again, and the response reports that it was replayed. Pass your own key to choose it. Charged calls get a fresh UUID key automatically. Pass your own for a retry that spans processes.
A key must be 16 to 255 visible ASCII characters. An empty or invalid key throws VaquillException before any request. ApiResponse.idempotentReplayed is true when the server replayed a stored answer. A replay is not charged again and not counted by the spend guard. The batch helpers suffix a caller key with -1, -2 and so on for chunks after the first, because each chunk has a different body.

Spend guard

maxCredits caps what this client, and clients derived from it, will spend. Charged calls are serialised by a coroutine Mutex while the cap is set, so the cap is exact even under heavy concurrency. See how the guard stays exact. When the cap is reached the call throws SpendGuardExceededException and nothing is sent. Free calls are never blocked. client.creditsSpent shows the running total.

Pagination and batch helpers

Every paginated endpoint has an iter... method returning a Paginator<T>, a cold set of Flows.
Charged endpoints spend credits on every page. Set maxPages or maxItems unless you mean to read everything.
truncated is true when a guard cut the result short. stuck is true when the server repeated the position it was just sent, or answered an empty page with hasMore: true. The loop stops instead of paying for the same page forever. Batch helpers de-duplicate, chunk and join the results.
  • statutes.resolveBatchAll(citations) sends 500 per call.
  • statutes.getSectionsAll(actIds) sends 50 per call.
  • sessionLaws.getBatchAll(ids) sends 200 per call.

Webhooks

Verify the raw request body, never re-serialised JSON.
  • Standard Webhooks signatures with a whsec_ base64 secret (or a plain UTF-8 secret), and a timestamp tolerance of 300 s by default.
  • Pass several secrets (secrets = listOf(new, old)) to accept both during a rotation.
  • An empty or blank secret, or a whsec_ secret that is not valid base64, throws IllegalArgumentException. A misconfigured environment can never accept a forged event.
  • Webhooks.verify checks the signature only. unwrap also parses the event.
  • The legacy X-Vaquill-Signature header is rejected unless you pass allowLegacy = true. It has no replay protection.
See Alerts for the payload and delivery behavior.

Versioning

A call is charged when the API declares the Idempotency-Key header on its operation. The SDKs derive the list of charged calls from the API contract, and prices are not hard-coded in them. Read the live prices with client.pricing.get(), which is free. The User-Agent is vaquill-kotlin/0.1.0 kotlin/<version> java/<version> <os>. A dedicated Java SDK also exists. For an endpoint newer than the SDK, use client.rawRequest(method, path, query, body, charged).
The release workflow, which signs the artifacts and uploads them to the Sonatype Central Portal, has never run. The first release may need fixes, and a release candidate tag is planned first.
Last modified on November 7, 2026