With doc.cheap’s passport OCR API, a Node.js server can send a Base64-encoded image to POST https://api.doc.cheap/v1/scans and receive structured scan JSON in the same request. The integration has three separate decisions to get right: check HTTP success, interpret the OCR result in meta.status, and save meta.billed with the scan record. For safe retries after timeouts, reuse the same idempotency key and identical request body for the same logical scan.
The endpoint, statuses, billing behavior, and limits below describe doc.cheap’s service, not a universal OCR standard. The provider’s tutorial by Teoh Chin Heng was published September 24, 2026, and updated September 26, 2026; check its current API documentation before deployment.
What the Node.js request sends and returns
The tutorial targets Node.js 18 or later, which includes built-in fetch. It reads an image file, encodes its bytes as Base64, and sends a JSON request to doc.cheap’s scan endpoint. The API responds synchronously with structured JSON rather than requiring a separate job-polling flow, according to the doc.cheap tutorial and API documentation.
Keep the API key on your server; do not expose it in browser code. The essential implementation pattern is to serialize the payload once and retain that exact serialized body for any retry:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import { readFile } from 'node:fs/promises';
import { randomUUID } from 'node:crypto';
const image = await readFile('./passport.jpg');
const payload = {
image: image.toString('base64'),
// Include only the options required by your integration.
};
const body = JSON.stringify(payload);
const idempotencyKey = randomUUID();
const response = await fetch('https://api.doc.cheap/v1/scans', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.DOC_CHEAP_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body,
});
const result = await response.json();
if (!response.ok) {
throw new Error(`Scan request failed: ${result.error?.code ?? response.status}`);
}
// HTTP success is not the same as successful text recognition.
console.log(result.meta.status, result.meta.billed);
This is a request-shape illustration; use the current documentation for the exact authentication header, payload fields, response schema, and supported options. In production code, also handle a response that is not valid JSON rather than assuming every error response has a parseable body.
Check HTTP success separately from the OCR outcome
Node’s fetch does not reject merely because the server returned an HTTP 4xx or 5xx response. Parse the response where possible and inspect response.ok for transport/API success. Only after that check should your application branch on meta.status, which describes what recognition did with the submitted image. A blurry or unsupported image can still receive HTTP 200.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
| Successful-HTTP status | Meaning and application response |
|---|---|
recognized |
Recognition returned document data. Store and validate the fields your application needs. |
no_document_found |
The image did not yield a detected document. Ask for a better-framed image rather than blindly resending the same one. |
unreadable |
The image could not be read clearly. Request better lighting, focus, or camera angle. |
unsupported_document |
The submitted document type is unsupported. Do not retry the same input expecting a different result. |
rejected |
The tutorial describes this as a service-side rejection that may merit one retry; avoid an unlimited retry loop. |
For non-2xx responses, inspect the documented error code and correct the cause. Input, size, authentication, and credit errors are not transient failures and should not be retried unchanged. See doc.cheap’s error-handling guidance for its provider-specific semantics.
Retry a timed-out scan without creating a second logical request
A timeout is ambiguous: the client may not know whether the service processed the request before the connection failed. Generate one idempotency key per logical scan, then reuse that key and byte-for-byte identical JSON body when retrying that scan. A new key means a new logical request; changing the body while keeping the old key is not a safe way to revise a submission.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
- Use a stable application identifier for the scan record and associate it with the idempotency key.
- Construct the request body once; do not rebuild it from mutable state for a retry.
- Retry only selected transient failures, with a timeout and bounded retry policy.
- Do not loop on authentication, invalid-input, size, or credit errors.
According to the tutorial, reusing a key with a different body returns 409 idempotency_conflict. It also describes a retention edge case: with retain_hours: 0, replay is unavailable for 24 hours, after which reuse may result in a new scan. Idempotency guarantees and retention are provider-specific, so verify the current contract before relying on a key for billing protection.
Persist the billed flag with the scan
meta.billed is a per-response field. Store it alongside the scan result and your own request identifier so reporting can distinguish responses the provider marks billable from those it does not. Do not infer cost solely from HTTP status or from whether OCR recognized the document.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Sandbox behavior needs separate treatment: doc.cheap says its public sandbox is not charged, even though its billed value simulates whether the corresponding live request would be billed. Therefore billed: true in a sandbox response is not evidence that money was charged. Keep environment or mode with your record if sandbox and live results share a database.
Protect passport images and interpret OCR narrowly
A passport image is sensitive personal data. Do not log the image, Base64 payload, or full request body. The tutorial says uploads are held in memory rather than written to durable storage, while results may be retained; it also says processing occurs in the EU and describes configurable result retention. These are vendor-published statements, not an independent security audit. Confirm the provider’s current retention, data handling, and processing terms for your use case.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
The tutorial also identifies a return_portrait: false option for omitting a portrait crop when your application does not need it. Use the least data your workflow requires, and test with a synthetic specimen rather than a real passport where possible.
OCR extracts and structures information; it does not establish that the document is genuine or that the person presenting it is its rightful holder. The tutorial describes authenticity.overall as not_checked. Do not present an OCR result or MRZ check as forgery detection or identity verification.
Provider terms and an SDK alternative
All figures here are doc.cheap product terms as reported in its 2026 tutorial or documentation, not independent industry statistics. Their availability and applicability can change:
| Term | doc.cheap figure and qualification |
|---|---|
| Public access | 10 free recognized documents per IP address in total, and up to 10 requests per hour, as reported in the tutorial published September 24, 2026, updated September 26, 2026. |
| Account allowance | 100 free documents each month, according to doc.cheap’s 2026 materials. |
| Live price | $0.01 per billed live document, according to doc.cheap’s 2026 materials. |
| Registered-key rate limit | 60 requests per minute, according to the tutorial’s 2026 account of the service. |
If you prefer an SDK, StructOCR documents a Node.js SDK with scanPassport() and Base64 conversion, as well as a JSON/Base64 REST API. That establishes an implementation alternative, not equivalent retry, billing, pricing, or retention behavior; its documentation does not provide a like-for-like comparison on those terms. See StructOCR documentation.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

