Extract Weighbridge Tickets with Python

Use the official StructOCR Python SDK to turn scale tickets into validated dictionaries for transport, quarry, waste, and agricultural workflows.

Weighbridge ticket OCR workflow mapping ticket number, vehicle, gross, tare, and net weight into structured JSON
StructOCR converts a photographed weighbridge ticket into normalized JSON and validates gross minus tare against the printed net weight.

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 Python 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 Python.

Where Python 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.

1
Upload
2
Results

Drop files here or click to browse

JPG · PNG · WebP  ·  up to 500 files · max 4.5 MB each

No files selected
Need more testing? Create a free account to get 200 free credits (equals 100 Weighbridge Ticket scans).

Implementation: Python SDK

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: Python 3.7+ and `pip install --upgrade structocr`

from structocr import StructOCR

client = StructOCR("YOUR_API_KEY", timeout=60)

# The SDK reads the file and sends the Base64 JSON request.
result = client.scan_weighbridge_ticket("weighbridge-ticket.jpg")

if result.get("success") and result["data"].get("is_valid"):
    data = result["data"]
    weights = data["weights"]

    print("Ticket:", data.get("ticket_number"))
    print("Vehicle:", data["vehicle"].get("registration"))
    print("Material:", data["material"].get("description"))
    print("Gross:", weights["gross"].get("value"), weights["gross"].get("unit"))
    print("Tare:", weights["tare"].get("value"), weights["tare"].get("unit"))
    print("Net:", weights["net"].get("value"), weights["net"].get("unit"))
    print("Weight check:", data["validation"].get("weight_check_passed"))
else:
    print("Review required:", result.get("data", {}).get("validation_error"))

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

Tutorial

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.

C# · Weighbridge Ticket
Tutorial

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.

Node.js · Weighbridge Ticket
Tutorial

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.

Go · Weighbridge Ticket
Tutorial

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.

PHP · Weighbridge Ticket
Tutorial

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.

Java · Weighbridge Ticket
Country Tutorial

US Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from US passports with a server-side integration.

Python · Passport
Country Tutorial

Poland Dowód Osobisty OCR Python SDK

Python Tutorial: Automate KYC in Poland. Extract data and MRZ from Dowód Osobisty using StructOCR Python SDK. Supports native text.

Python · dowód osobisty
Country Tutorial

Mexico INE OCR API & Python SDK

Python Tutorial: Automate KYC in Mexico. Extract data from INE cards using our SDK. Upload your ID image to test the OCR engine live—no signup required. Supports native text and MRZ.

Python · ine credencial
Country Tutorial

Vietnam CCCD OCR Python SDK

Python Tutorial: Automate KYC in Vietnam. Extract data from the Vietnamese Identity Card (Căn cước công dân / CCCD) using StructOCR Python SDK. Supports native text, diacritics, and MRZ extraction.

Python · cccd
Country Tutorial

Morocco CNIE OCR Python SDK

Python Tutorial: Automate KYC in Morocco. Extract data from CNIE using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · cnie

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

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.

Instant Access Cancel Anytime 99.9% Uptime