Java SDK
Available
A typed client of the HTTP API for Java systems.
vn.theio.croppath:croppath-sdk is a typed Java client of the whole HTTP API, for packing houses and ERP integrations. The operations are grouped as in the reference (client.lots(), client.packing(), client.shipping(), ...); each method returns the decoded model or throws a typed, unchecked error. Java 17 or later, with the JDK's own HTTP client; its only runtime dependencies are jackson-databind and jackson-datatype-jsr310. A CropPathClient is thread-safe: build one per base URL and credential and share it.
Download the SDK's jar (vn.theio.croppath:croppath-sdk), its pom and their .sha256 files from this portal's Downloads page (/developers/downloads), check their SHA-256, then install them into your local Maven repository as below. CropPath distributes its SDKs only through this portal, not through public package registries.
for f in croppath-sdk-0.3.0.jar croppath-sdk-0.3.0.pom; do
curl -fLO https://txng.theio.vn/developers/downloads/sdk/$f && curl -fLO https://txng.theio.vn/developers/downloads/sdk/$f.sha256 && sha256sum -c $f.sha256
done # macOS: shasum -a 256 -c instead of sha256sum -c
mvn install:install-file -Dfile=croppath-sdk-0.3.0.jar -DpomFile=croppath-sdk-0.3.0.pomimport vn.theio.croppath.sdk.CropPathClient;
import vn.theio.croppath.sdk.gen.model.Lot;
CropPathClient client = CropPathClient.builder()
.baseUrl("https://txng.theio.vn")
.apiToken(System.getenv("CROPPATH_TOKEN")) // an API token: Settings > API tokens
.tenant("coop-dl") // sent as X-Tenant
.build();
Lot lot = client.lots().getLot("LO-260928-014");
System.out.println(lot.getStatus());Credentials: an API token, or OAuth2 client credentials (the client asks /v1/oauth/token for a short-lived token with its id and secret, reuses it until shortly before it expires, and asks for a new one once when the API answers 401), or a token source of your own. The token is sent only as Authorization: Bearer and only to the base URL; redirects are never followed; the base URL must be https:// except for a loopback address (localhost); and no error message contains a token or a secret.
Retries: the POSTs that take an Idempotency-Key (create lot, open session, allocate fruit, cartons, seal, shipment, depart, ...) get a random key when you set none, and keep it on every retry, so the API replays its stored answer instead of running the action twice. Set your own key when you store it with your record of the action. Only GET, HEAD and those POSTs are retried: after a network error, a timeout, 429, 502, 503 or 504 (and 409 idempotency_key_in_use for a keyed POST), 3 attempts in all by default, honouring Retry-After up to 30 seconds. Every other write is sent once: after a lost answer, read the resource back before you send it again.
Also included: typed errors by HTTP status (with the API's code and the request id), pagination helpers that follow next_cursor and always stop (by default after 1,000 pages, and 10,000 items when collecting a whole list), the live streams of a measurement session and of the device message log (reconnecting with Last-Event-ID), and a webhook verifier that compares the signature in constant time and refuses a timestamp more than 300 seconds from your clock.