The Best Java API for Shipping Container OCR
Stop using regex. Extract structured data from Shipping Containers with 99% accuracy using Java.

The Problem with Shipping Container Parsing in Java
Enterprise Java applications in logistics often struggle with legacy OCR libraries like Tesseract or JavaCV wrappers. These traditional tools fail when processing shipping containers due to heavy rust, physical damage, vertical text orientations, and skewed angles from terminal gate cameras. Attempting to build custom regex parsers for ISO 6346 standards on top of poor OCR results leads to brittle codebases and high manual intervention rates.
The StructOCR Solution
StructOCR allows your Java backend to offload complex image processing to our specialized deep learning models. Our API handles deskewing, vertical text reading, and automatically performs ISO 6346 compliant extraction. By returning validated JSON directly to your Java application, you can seamlessly integrate high-accuracy container data into your logistics and port automation systems without maintaining heavy machine learning dependencies.
Common Use Cases
- Terminal Automation: Speed up gate operations and yard management by instantly capturing container numbers.
- Customs & Compliance: Automate cross-border document verification and manifesting within enterprise ERPs.
- Asset Tracking: Monitor shipping container movements across the global supply chain with real-time data.
Live Demo: Container OCR
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: Raw API Request
Complete, runnable Java 11+ code to directly upload an image and extract data from a Shipping Container.
Prerequisite: JDK 11+ and Gson library
// 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
// 👉 https://structocr.com/register
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
public class ContainerOcr {
public static void main(String[] args) throws IOException, InterruptedException {
String apiKey = "YOUR_API_KEY"; // Replace with your actual API key
String imagePath = "path/to/your/container_image.jpg"; // Replace with the path to your image
// 1. Create the HTTP client
HttpClient client = HttpClient.newHttpClient();
// 2. Build the HTTP request (Direct File Upload)
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.structocr.com/v1/container"))
.header("x-api-key", apiKey)
.header("Content-Type", "application/octet-stream")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of(imagePath)))
.build();
System.out.println("Uploading image to StructOCR API...");
// 3. Send the request and receive the response
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// 4. Parse the JSON response
Gson gson = new Gson();
JsonObject jsonResponse = gson.fromJson(response.body(), JsonObject.class);
// 5. Extract the Container data
if (jsonResponse.has("success") && jsonResponse.get("success").getAsBoolean()) {
JsonObject data = jsonResponse.getAsJsonObject("data");
String containerNumber = data.get("container_number").getAsString();
boolean isValid = data.get("is_valid").getAsBoolean();
System.out.println("✅ Extraction Successful!");
System.out.println("Container Number: " + containerNumber);
System.out.println("Is Valid (ISO 6346): " + isValid);
System.out.println("Confidence: " + data.get("confidence").getAsString());
if (data.has("parsed")) {
JsonObject parsed = data.getAsJsonObject("parsed");
System.out.println("--- Parsed Details ---");
System.out.println("Owner Code: " + parsed.get("owner_code").getAsString());
System.out.println("Category: " + parsed.get("category").getAsString());
System.out.println("Serial Number: " + parsed.get("serial_number").getAsString());
System.out.println("Check Digit: " + parsed.get("check_digit").getAsString());
}
} else {
String errorMsg = jsonResponse.has("error") ? jsonResponse.get("error").getAsString() : "Unknown Error";
System.out.println("❌ Error: " + errorMsg);
}
}
}
Technical Specs
- •Latency: < 4s (Average)
- •Uptime: 99.9% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (Max 4.5MB) via Direct File Upload
- •Output: JSON (Structured Data)
Key Features
- •Smart Crop: Auto-detects container boundaries.
- •ISO 6346 Validation: Cross-validates owner codes and checksums automatically.
- •Specialized Models: Trained specifically on vertical and degraded Shipping Container text.
Sample JSON Response
The API returns a clean JSON object with normalized, parsed container fields.
{
"success": true,
"data": {
"container_number": "TTNU5194822",
"is_valid": true,
"confidence": "High",
"parsed": {
"owner_code": "TTN",
"category": "U",
"serial_number": "519482",
"check_digit": "2"
}
}
}Frequently Asked Questions
What file formats are supported?
JPG, PNG, and WebP images up to 4.5MB.
Is data stored?
No. Images are processed in-memory and deleted immediately.
How to handle errors?
Check the 'success' flag and 'error' message in the response.
You May Also Like
Related tutorials, platform guides, and comparisons
C# Shipping Container OCR API
Upload an image for a free test! Tutorial: Learn how to use the StructOCR C# Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schemas.
Node.js Shipping Container OCR API
Tutorial: How to use the StructOCR Node.js SDK to extract data from Shipping Containers. Upload an image for a free test! Includes code samples and JSON schema.
Python Shipping Container OCR API
Tutorial: Learn how to use the StructOCR Python SDK for shipping container OCR. Upload an image for a free test! Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schemas.
Go Shipping Container OCR API
Upload an image for a free test! Tutorial: Learn how to use the StructOCR Go Client to extract data from Shipping Containers. Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schema.
PHP Shipping Container OCR API
Tutorial: Learn how to use the StructOCR PHP Client via cURL for shipping container OCR. Upload an image for a free test! Extract ISO 6346 container numbers with 99% accuracy. Includes code samples and JSON schemas.
Java Vehicle Registration OCR API
Java Vehicle Registration OCR API tutorial. Upload an image for a free test! Accurately extract standardized fields like VIN, make, and model, along with dynamically localized data for global documents.
Ghana Ghana Card OCR Python SDK
Python Tutorial: Automate KYC in Ghana. Extract data, Personal ID Number, and validate TD1 MRZ from Ghana Card using StructOCR Python SDK.
Germany Personalausweis OCR Python SDK
Python Tutorial: Automate KYC in Germany. Extract data from Personalausweis and validate TD1 MRZ using StructOCR Python SDK. Supports native German text.
Germany Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Germany passports with a server-side integration.
Germany Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Germany passports.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Manual TOS Entry vs. Container OCR Automation API
Analyzing the ROI and operational efficiency of replacing manual gate checkers with an automated Container OCR API in logistics yards.
Add Container OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a Replit application. Build logistics and yard management tools using Replit Agent and Secrets.
Tesseract OCR vs. StructOCR API for ISO 6346 Container Numbers
A technical comparison for developers evaluating open-source Tesseract vs. a dedicated cloud API for extracting shipping container numbers.
Add Container OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a v0 by Vercel app. Build logistics and yard management tools with zero backend.
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 Container OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API using the Cursor AI code editor. Build logistics and yard management tools rapidly.
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.