Call a Weighbridge Ticket OCR API from Go
Build a small Go client for scale-ticket images and receive normalized weights plus machine-readable review reasons.

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 Go 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 Go.
Where Go 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: Go REST Client
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: Go 1.22+ using the standard library
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"os"
"time"
)
func main() {
image, _ := os.ReadFile("weighbridge-ticket.jpg")
body, _ := json.Marshal(map[string]string{
"img": base64.StdEncoding.EncodeToString(image),
})
req, _ := http.NewRequest("POST", "https://api.structocr.com/v1/weighbridge-ticket", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", "YOUR_API_KEY")
client := &http.Client{Timeout: 60 * time.Second}
res, err := client.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { panic(res.Status) }
var result map[string]any
json.NewDecoder(res.Body).Decode(&result)
data := result["data"].(map[string]any)
fmt.Println("Ticket:", data["ticket_number"])
fmt.Println("Weights:", data["weights"])
fmt.Println("Validation:", data["validation"])
}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
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.
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.
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.
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.
Go VIN OCR API
Upload an image for a free test! Tutorial: How to use the StructOCR Go Client to extract data from VIN (Vehicle Identification Number)s. Includes code samples and JSON schema.
Go Driver License OCR API
Upload an image for a free test! Struggling with manual driver's license data entry? Our Go API delivers structured JSON in <5s, boasting 98.5% uptime and SOC2 compliance with AES-256 encryption.
Go Passport OCR API
Upload an image for a free test! Extract passport data via a simple REST API in Go. Get high-accuracy, ICAO-compliant JSON output from noisy images. Eliminate manual entry errors.
Go License Plate OCR API
Golang License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.
Go Vehicle Registration OCR API
Golang 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.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Passport OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Replit application. Build travel, hospitality, and global KYC flows using Replit Agent and Secrets.
Add Receipt OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a Replit application. Build expense tracking and receipt scanning tools using Replit Agent and Secrets.
Add VIN OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a Replit application. Build automotive and fleet tools using Replit Agent and Secrets.
Single-Page MRZ SDKs vs. Dual-Page Indian KYC API
Why traditional MRZ scanners fail at full Indian Passport verification, and how to process both the front identity page and the back address page in a single API call.
Template-Based OCR vs. StructOCR API for Invoice Processing
Why traditional zonal/template-based OCR fails at processing vendor invoices, and how layout-agnostic AI APIs instantly extract line items and totals.
Tesseract & PassportEye vs. StructOCR Passport API
A technical evaluation for developers deciding between open-source MRZ scanners and a dedicated cloud-based Passport OCR API.
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.