Call a Weighbridge Ticket OCR API from PHP
Connect a PHP application to the weighbridge endpoint and turn photographed tickets into normalized operational records.

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 PHP 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 PHP.
Where PHP 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: PHP cURL
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: PHP 8.1+ with the cURL extension
<?php
$payload = json_encode([
'img' => base64_encode(file_get_contents('weighbridge-ticket.jpg')),
]);
$ch = curl_init('https://api.structocr.com/v1/weighbridge-ticket');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'x-api-key: YOUR_API_KEY',
],
CURLOPT_POSTFIELDS => $payload,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) throw new RuntimeException($body ?: 'OCR request failed');
$data = json_decode($body, true, flags: JSON_THROW_ON_ERROR)['data'];
echo 'Ticket: ' . ($data['ticket_number'] ?? 'unknown') . PHP_EOL;
echo 'Net kg: ' . ($data['weights']['net']['normalized_kg'] ?? 'unknown') . PHP_EOL;
echo 'Needs review: ' . json_encode($data['validation']['needs_review']) . PHP_EOL;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
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.
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.
Java Weighbridge Ticket OCR API Tutorial
Integrate a weighbridge ticket OCR API in Java. Extract ticket, vehicle, material, gross, tare, net, and review signals from images or PDFs.
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.
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.
PHP Invoice Line Item OCR API
Struggling with manual invoice data entry? Our PHP invoice line item OCR API processes documents in <3s, outputting structured JSON. Upload an image for a free test! SOC2 compliant & AES-256 encrypted.
PHP Passport & Visa OCR API
Enterprise-grade PHP Passport & Visa OCR API. Test our instant JSON extraction for free. Accurate ICAO 9303 & identity document parsing with zero RegEx required.
PHP HIN (Hull Identification Number) OCR API
Tutorial: How to use the StructOCR PHP API to extract HIN from images. Upload an image for a free test! Includes native cURL code samples and marine OCR solutions.
PHP Vehicle Registration OCR API
PHP 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.
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.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Passport OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Lovable.dev app through a secure server-side function for travel and KYC flows.
Add Receipt OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a Lovable.dev app. No backend required — just paste a prompt and add your API key.
Add VIN OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a Lovable.dev app. Build automotive and fleet tools with zero backend required.
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.
OpenALPR vs. StructOCR API for VIN Decoding
Why traditional License Plate Recognition (ALPR) engines are not suitable for scanning Vehicle Identification Numbers (VINs).
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.
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.