Call a Weighbridge Ticket OCR API from Java
Add structured scale-ticket extraction to a Java service with one Base64 JSON request and deterministic weight validation.

Why Weighbridge Tickets Need More Than Plain OCR
A scale ticket may place the same three measurements in different rows, reverse the order of the first and second weighing, abbreviate units, or mix ticket, vehicle, job, and material identifiers. A generic OCR engine returns text but leaves your application to decide which value is gross, tare, or net. That brittle parsing becomes harder across quarry, waste, grain, logistics, and recycling layouts.
A Structured Java Workflow
The StructOCR Weighbridge Ticket OCR API returns a stable schema for ticket, facility, vehicle, material, and weight data. It preserves each printed value, normalizes supported units to kilograms, and runs deterministic gross-minus-tare validation. Test a sample first with the free weighbridge ticket scanner, then use the same endpoint in Java.
Where Java Teams Use Weighbridge OCR
- Transport and Dispatch: Match ticket numbers and vehicle registrations to loads without retyping paper tickets.
- Quarry and Waste Operations: Capture material, customer, job, gross, tare, and net values for downstream reconciliation.
- Exception Review: Route missing weights, unit issues, or printed net mismatches to a human using machine-readable review reasons.
Live Demo: Weighbridge Ticket OCR Scanner
No registration required. Upload a file to test the extraction.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
Implementation: Java HttpClient
The request uses POST /v1/weighbridge-ticket. Send one Base64-encoded JPG, PNG, WebP, or PDF in the img property and allow a 60-second client timeout. See the complete API reference for the full response and error contract.
Prerequisite: Java 17+ and Jackson Databind
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Base64;
ObjectMapper mapper = new ObjectMapper();
String image = Base64.getEncoder().encodeToString(
Files.readAllBytes(Path.of("weighbridge-ticket.jpg"))
);
String body = mapper.writeValueAsString(java.util.Map.of("img", image));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.structocr.com/v1/weighbridge-ticket"))
.timeout(Duration.ofSeconds(60))
.header("Content-Type", "application/json")
.header("x-api-key", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) throw new RuntimeException(response.body());
JsonNode data = mapper.readTree(response.body()).path("data");
System.out.println("Ticket: " + data.path("ticket_number").asText());
System.out.println("Net kg: " + data.path("weights").path("net").path("normalized_kg"));
System.out.println("Needs review: " + data.path("validation").path("needs_review"));Technical Specs
- •Endpoint: POST /v1/weighbridge-ticket
- •Authentication: x-api-key request header
- •Input: Base64 or data URI in JSON; JPG, PNG, WebP, or PDF
- •Maximum decoded size: 4.5MB
- •Cost: 2 credits per successful request
- •Output: Structured JSON with deterministic weight validation
Key Features
- •Raw plus normalized weights: Preserve printed text while receiving numeric values and normalized_kg.
- •Transparent arithmetic: calculated_net_kg, difference_kg, and weight_check_passed explain the validation result.
- •Review routing: needs_review and review_reasons identify missing fields, unit problems, and mismatches.
- •Wrong-document handling: Unrelated documents return is_weighbridge_ticket false instead of a forced ticket result.
Example Validated JSON Response
The API separates extracted fields from deterministic validation so your application can store the record and make an explicit review decision.
{
"success": true,
"data": {
"is_weighbridge_ticket": true,
"document_type": "generic_weighbridge_ticket",
"ticket_number": "1042",
"facility": {
"name": "North Yard Scale",
"address": null,
"scale_id": "SCALE-2"
},
"vehicle": {
"registration": "AB12 CDE",
"trailer_registration": null,
"fleet_number": null,
"driver_name": null
},
"material": {
"description": "Recycled aggregate",
"code": "RA20"
},
"weights": {
"gross": {
"value": 25330,
"unit": "kg",
"raw": "25,330 kg",
"normalized_kg": 25330
},
"tare": {
"value": 6770,
"unit": "kg",
"raw": "6,770 kg",
"normalized_kg": 6770
},
"net": {
"value": 18560,
"unit": "kg",
"raw": "18,560 kg",
"normalized_kg": 18560
}
},
"confidence": "high",
"is_valid": true,
"validation_error": null,
"validation": {
"calculated_net_kg": 18560,
"difference_kg": 0,
"weight_check_passed": true,
"needs_review": false,
"review_reasons": []
}
}
}Frequently Asked Questions
Which weighbridge ticket layouts are supported?
The endpoint handles general weighbridge and scale tickets, weighment slips, quarry load tickets, dump or disposal tickets, and grain scale tickets. Unknown but valid layouts use a generic weighbridge ticket classification.
Does the model calculate net weight?
The model only extracts printed values. Application code separately calculates gross minus tare, compares it with the printed net value, and returns the difference and review reasons.
Can I upload a file directly to the REST endpoint?
The REST endpoint currently accepts JSON containing a Base64 value or data URI in the img property. The official Python and Node.js SDKs read local files and perform that encoding for you.
How should I handle a low-confidence result?
Check is_valid, confidence, validation.needs_review, and validation.review_reasons before posting the record into an operational system. Retain a human review path for flagged tickets.
You May Also Like
Related tutorials, platform guides, and comparisons
C# Weighbridge Ticket OCR API Tutorial
Integrate weighbridge ticket OCR in C# and .NET. Send a Base64 image and extract vehicle, material, gross, tare, net, and validation fields as JSON.
Python Weighbridge Ticket OCR API Tutorial
Build a Python weighbridge ticket OCR workflow. Extract ticket, vehicle, material, gross, tare, and net weights into validated JSON with the StructOCR SDK.
Node.js Weighbridge Ticket OCR API Tutorial
Build a Node.js weighbridge ticket OCR integration. Extract ticket, vehicle, material, gross, tare, and net weights with the official StructOCR SDK.
PHP Weighbridge Ticket OCR API Tutorial
Integrate weighbridge ticket OCR in PHP. Extract ticket number, vehicle, material, gross, tare, net, and validation data from Base64 images.
Go Weighbridge Ticket OCR API Tutorial
Build a Go weighbridge ticket OCR client. Send Base64 images and parse vehicle, material, gross, tare, net, and weight validation results.
Java OCR Invoice API
Upload an invoice to try our live demo. High-accuracy Java OCR invoice API for accounts payable. Extract line items directly into JSON.
Java HIN OCR API
Upload an image for a free test! Tutorial: Learn how to integrate the StructOCR API into your Java enterprise applications to extract structured data from Hull Identification Numbers (HIN).
Java Passport OCR API
Achieve 99%+ accuracy for Passport MRZ and VIZ data extraction in Java. Upload an image for a free test! Our API provides structured JSON output, handling glare and blur automatically.
Java Receipt OCR API
Tutorial: Integrate StructOCR's Receipt API into your Java enterprise applications. Upload an image for a free test! Extract line items, merchants, and taxes from POS receipts into structured JSON.
Java Shipping Container OCR API
Upload an image for a free test! Tutorial: Learn how to use the StructOCR Java Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
AWS Textract & Google Vision vs. StructOCR Passport API
Why generic cloud OCR APIs fail at structured KYC automation, and why developers choose specialized Passport APIs instead.
Add Container OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a Bolt.new app. Build logistics and yard management tools right in your browser.
Add Driver's License OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Bolt.new app. Build car rental and mobility onboarding flows right in your browser.
Add HIN OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API into a Bolt.new app. Build marine and boat management tools right in your browser.
Invoice OCR API Integration for Bolt.new
Learn how to integrate our Invoice OCR API into a Bolt.new app in under 5 minutes. Extract structured JSON effortlessly. Try our free live test now.
Add National ID OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Bolt.new app. Build KYC and identity verification flows right in your browser.
From tutorial to production in 5 minutes.
You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.