Replit Tutorial5 min setupDeveloper friendly

Add Container OCR to Your Replit App in 5 Minutes

Replit Agent scaffolds your full-stack application. StructOCR reads the corrugated steel. Here's the exact prompt and API call to wire them together using Replit Secrets for instant yard management.

Diagram showing a shipping container photo uploaded into an app running on Replit, sent to the StructOCR API, and returned as structured JSON containing the parsed ISO 6346 container number.
Upload β†’ parse β†’ display: the full flow takes a single API call.

Why Replit + StructOCR is a natural fit for Logistics Apps

Replit generates full-stack applications instantly from natural language using Replit Agent. It provisions the database, configures the server routes, and spins up frontend components seamlessly β€” but extracting an 11-character ISO container number from rusted, corrugated steel doors is something you need an explicit data pipeline to handle. StructOCR fills exactly that gap: one API call, structured JSON back. Tell Replit Agent what you want, paste in the fetch code below, and your cloud-hosted yard management app is live.

The problem: Standard AI can't read vertical text on rusted steel

Cloud-based AI environments like Replit are remarkable at writing boilerplates and orchestrating backend environments β€” but they stop at the boundary of specialized document parsing. You can build a beautiful freight tracking interface in minutes, yet the actual extraction of an 11-character container number from vertically stacked text on corrugated steel doors requires a dedicated Container OCR API. Standard vision models routinely fail to read text split across metal ridges or stacked top-to-bottom.

The solution: ISO 6346 precision, instantly

StructOCR's /v1/container endpoint accepts an image stream and returns a clean, fully typed JSON object with the validated ISO 6346 container number, instantly decoding the owner prefix, category, and check digit. Because it runs as a pure REST API, your Replit container can talk to it effortlessly via a zero-dependency server-side request.

Integrate StructOCR in Replit (3 Steps)

  1. Describe your app to Replit Agent

    Open replit.com and start a new workspace using Replit Agent. Describe the logistics tool you want to build β€” be explicit about the scanning interface.

    Try this prompt: "Build a mobile-friendly yard management application using React and Node.js. Users can upload a photo of shipping container doors, and the app will display the extracted container number, owner code, and check digit."
  2. Instruct the Agent to connect to the StructOCR endpoint

    Once the foundational UI and backend scaffolding are ready, paste the follow-up prompt into the Agent chat panel. Replit Agent will generate the network logic, wire up file stream uploads, and pipe the extracted data safely to your view state.

    Follow-up prompt: "When a user uploads a container image, create a backend endpoint that forwards it as a multipart/form-data POST request to https://api.structocr.com/v1/container. Authenticate using the bearer token stored in process.env.STRUCTOCR_KEY. Return the JSON payload back to the client UI."
    // Replit Agent wires this up inside your Express/Next server handler securely const response = await fetch('https://api.structocr.com/v1/container', { method: 'POST', headers: { Authorization: `Bearer ${process.env.STRUCTOCR_KEY}` }, body: formData, });
  3. Add your StructOCR API key to Replit Secrets

    Navigate to the Tools β†’ Secrets menu in your Replit editor workspace sidebar. Add a new key named STRUCTOCR_KEY and paste your private API token into the value field. The workspace environment automatically loads the variable.

    Variable name: STRUCTOCR_KEY β€” get your free key at structocr.com/dashboard
    Key: STRUCTOCR_KEY Value: sk_live_xxxxxxxxxxxxxxxx

What you can build in Replit with this integration

  • Gate automation app: Let truck drivers or gate inspectors snap a photo of the container to automatically log the entry/exit time and verify the container number against the manifest.
  • Yard management system (YMS): Build a mobile app for yard jockeys to scan container numbers and update parking slot locations in real-time. A core feature of modern logistics automation hosted in cloud environments.
  • Freight forwarding tracker: Create a tool where warehouse staff scan containers during loading/unloading to generate instant status updates for end-customers.
  • Damage inspection portal: Add an upload step to a container inspection flow: extract the container number automatically from the damage photos to link the evidence to the correct asset.

The prompt and the code

Copy the follow-up prompt text into your Replit Agent chat interface to implement the bridge handler. The backend example indicates how Replit typically handles file proxying to protect production secrets.

Prerequisite: A free StructOCR account β€” get your API key at structocr.com/dashboard (no credit card required)

I need to add shipping container OCR to this application using a secure backend endpoint.

When a file is uploaded to our express app:
1. Forward it as multipart/form-data to: POST https://api.structocr.com/v1/container
2. Include the header: Authorization: Bearer ${process.env.STRUCTOCR_KEY}
3. The response is JSON with fields: data.container_number, data.is_valid, data.parsed.owner_code, data.parsed.check_digit
4. Pass this object to the client so it can display the extracted container number and the decoded parts in the results panel
5. Show a loading spinner while the request is in flight
6. Show an error message if the upload fails

Read the API token using process.env.STRUCTOCR_KEY.

What the API returns

Not just the raw stringβ€”the API automatically validates the check digit and breaks down the components. Your cloud application built via Replit Agent can bind this data structure directly.

{
  "success": true,
  "data": {
    "container_number": "ZCSU8921655",
    "is_valid": true,
    "confidence": "High",
    "parsed": {
      "owner_code": "ZCS",
      "category": "U",
      "serial_number": "892165",
      "check_digit": "5"
    }
  }
}

Technical Specs

  • Formats accepted: PNG, JPG, WEBP β€” optimized for yard and port mobile photos
  • Response time: typically under 1 second
  • Condition handling: robust against rust, dirt, corrugated shadows, and nighttime yard lighting
  • Algorithm checks: built-in ISO 6346 Check Digit validation to ensure absolute accuracy
  • Layout support: reads text printed horizontally, vertically, or stacked

Key Features

  • ISO 6346 Decoding: automatically parses the 11-character string into Owner Code, Category, Serial, and Check Digit
  • Checksum validation: mathematically verifies the container number to eliminate OCR misreads (like confusing '0' and 'O')
  • Multi-angle support: reads numbers skewed or taken from extreme angles while the truck is moving
  • Edge computing ready: lightweight API payload designed for fast connectivity in rural yards or ports with poor cellular service

Live Demo: Container OCR

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

Frequently Asked Questions

Does StructOCR work inside a Replit environment?

Yes. StructOCR exposes standard, cloud-agnostic REST endpoints. Replit Agent can easily generate backend Express handlers or client-side fetches to communicate with it.

Where should I store the StructOCR API key within Replit?

Always use the built-in Secrets tool window (available under the tools tab in the workspace). Never hardcode your API tokens into files like `index.js` or save them inside standard text config blocks, to prevent accidental public exposures on shared forks.

Can it read container numbers written vertically?

Yes. Our container model is trained specifically on intermodal shipping containers and seamlessly handles vertically stacked, horizontal, and multi-line layouts.

How does the API prevent misreads on rusty containers?

StructOCR automatically applies ISO 6346 mathematical checksum validations. If a letter or number is obscured by rust, the API uses the check digit to verify and correct the 11-character string, ensuring 100% accuracy on valid containers.

How can I test the accuracy before building?

You can verify the model live with your own shipping container photos using our free container scanner tool.

Is there a free tier to test with?

Yes. StructOCR's free plan includes 10 scans per month with no credit card required. Check out our pricing page for full details.

More Tutorials

Precise Data Extraction and Seamless Integration with AI-powered OCR API.

Empower your solutions with automated data extraction by integrating best-in class StructOCR via API seamlessly.

No credit card required β€’ Full API access included