China Business License OCR API in Node.js
Send a Chinese business license image from Node.js, read the recognized fields, and retain enough image context for a reviewer to correct the result.
Extract registered fields from a Chinese business license image, along with available confidence scores and image coordinates.

An onboarding service receives an image of a Chinese business license. The developer wants to prefill the company name and Unified Social Credit Code, keep the source image under the existing access policy, and let a reviewer open the same image when a value is unclear. A Node.js server can send the image bytes directly to ChinaValidate, receive the recognition response, and return a small review record to the application.
For a private upload, use the documented binary request to the Business License Recognition API. The alternative JSON form accepts a publicly accessible image URL. Choosing the binary form lets the intake service use the protected copy it already has. Keep recognition as a proposed transcription. An identity check against a company record can follow after the reviewer confirms the identifying field. ChinaValidate business license recognition API
The binary request
The recognition endpoint accepts supported image formats in a binary body using application/octet-stream. Its documentation lists PNG, JPG, JPEG, BMP, GIF, TIFF, and WebP, up to 10 MB. For a binary request, put the optional language parameter in the query string. For a URL request, send JSON containing image_url and any selected language. The two representations are alternatives for the same call.
Use the intake service to enforce the file policy that applies to your users. Check the actual file type using your existing upload validation. A suffix is a hint from the sender. It tells the service less than a checked file type. A scan exported as a PDF should go back through the intake flow for an appropriate image rather than being renamed to look like one. Keep the upload size within a supportable limit for your application as well as the API limit. An early file rejection provides a useful message and keeps the request out of the recognition queue.
The following example uses the stable Node.js fetch implementation available in current supported versions. It sends one file selected by the operator. The same request can receive a verified byte buffer from an upload handler, without exposing a file path or interpreting an arbitrary URL in the handler. The code deliberately separates a transport failure, an application failure, and a completed observation with insufficient recognized data. Node.js fetch and AbortSignal documentation · Node.js file system documentation
import { readFile, stat } from "node:fs/promises";
const [, , inputPath] = process.argv;
const apiKey = process.env.CHINAVALIDATE_API_KEY;
const maxBytes = 10_000_000;
if (!inputPath || !apiKey) {
throw new Error("Provide an image path and CHINAVALIDATE_API_KEY.");
}
const info = await stat(inputPath);
if (!info.isFile() || info.size === 0 || info.size > maxBytes) {
throw new Error("Provide a supported image within the upload limit.");
}
const image = await readFile(inputPath);
if (image.length === 0 || image.length > maxBytes) {
throw new Error("Image size is outside the upload limit.");
}
const endpoint = new URL(
"https://api.chinavalidate.com/v1/business-licenses/recognize"
);
endpoint.searchParams.set("language", "zh-CN");
const response = await fetch(endpoint, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/octet-stream"
},
body: image,
signal: AbortSignal.timeout(30_000)
});
if (!response.ok) {
throw new Error(`Recognition HTTP failure: ${response.status}`);
}
const result = await response.json();
if (result.code !== 200) {
throw new Error(`Recognition application response: ${result.code}`);
}
const item = result.data?.items?.[0];
const proposed = item?.fields ?? {};
const review = {
request_id: response.headers.get("X-CV-Request-Id"),
company_name: proposed.company_name ?? null,
credit_code: proposed.unified_social_credit_code ?? null,
needs_review: !proposed.company_name || !proposed.unified_social_credit_code
};
console.log(JSON.stringify(review));
Save the example as an ES module and provide the key through the server's secret configuration before invoking it with a permitted license image. It performs a real request when supplied with a valid key. Any logged output stays in a private development session for this example. In an application, write the proposed name and code to your access-controlled review record and limit operational logs to the request ID, an internal document reference and outcome. Choose the timeout as part of your application's own handling. A timeout can occur while work is still in progress at the service. Preserve the attempt and review it before sending another chargeable call.
The sample checks the actual byte length once more after reading the file. A web service should enforce its ingress limit before buffering a request in memory. If several 10 MB images can arrive together, cap the number admitted for recognition using the application's resource policy. A bounded intake has a predictable memory cost. Reporting an unsupported file at intake is different from recording an API request that returned no usable transcription.
A useful response for the reviewer
The endpoint documentation describes recognized values in fields and available value confidence and image coordinates in field_details. Keep the original item associated with the source image and the attempt. Use the recognized company name and code to fill draft fields. A reviewer can correct those draft values while retaining the original response for comparison. A high recognition score describes the extraction and should be interpreted in the context of the image and the field's role.
The market regulator's company registration implementation measures list information carried on a company business license, including company name, address, legal representative, registered capital, company type and business scope. The exact set of fields and their appearance on a submitted image still matter to an intake flow. Name, address and registration date can be long or visually adjacent. Give the reviewer a way to see the whole document and isolate one proposed value without losing the section around it. SAMR company registration implementation measures
| Observation during intake | State to show in the application |
|---|---|
| Upload is empty or fails local file validation | Explain what image the user needs to submit |
| Network request fails before an application response is obtained | Show an unfinished recognition attempt and retain the source |
| API supplies an application error | Show a request failure and route the recorded code to the proper owner |
| Recognition succeeds and a required value is missing | Show the usable fields and ask a reviewer to supply the missing value |
| Required values are present | Prefill the draft and give the reviewer access to the source image |
| A later company lookup confirms a different current address | Keep both dated values and show the difference for review |
The coordinate data is most useful when the application can associate it with the exact version sent to recognition. If the viewing surface uses a rotated or resized copy, compare the response's image attributes and the transform used for rendering before drawing any field highlights. Provide the full image when you cannot establish a safe mapping. An incorrect highlight can direct a reviewer away from the field they need. A plain review form with a source link remains usable while image positions are unavailable.
Keep document intake and company lookup linked
If the reviewer confirms an 18-character code, pass it as a string to the company profile API, or use the exact confirmed Chinese legal name. Store the company observation separately from the OCR result, with its own timestamp and source. For example, if the scanned address differs from the profile, the record should show which value appeared on the scan and which value was returned during lookup. A new observation can be appended without silently rewriting the document. For the same reason, save changes made by the reviewer independently of what recognition returned. Company profile API inputs and response
An upload that contains a valid-looking code but has the wrong seller name for the proposed contract requires a different decision. Have the buyer reconcile the name and identifier against the agreement before finalizing the company record. If a newer image is submitted, assign it a source version and keep its recognition response with that version. One internal company ID may link to several documents and checks over time. The intake record should show the evidence used for the specific decision.
In a bilingual form, keep the original Chinese name even when the visible columns use a translated result. The stable credit code can be copied into an ordinary text field. Let the buyer compare the contract name with the original script and copy the exact characters if the company lookup accepts a legal name. Store the user's correction as a value the reviewer confirmed, with its own source and time. That record can be useful in a later dispute about why a purchase was associated with a particular legal company.
Tests before enabling paid calls
Run the server against a stub transport or controlled fixture first. Exercise a completion with a recognized name and code, one with a missing field and one with an application failure. Check that the same image source can be opened from all three. Test a request that times out after sending, and make sure the UI reports an unfinished attempt without assuming a result. An explicit repeat can then create a new attempt, linked to the same source when the source has not changed.
Check a valid code with leading or visually ambiguous characters as a string and ensure the returned value reaches the form unchanged. Compare an image shown at its native dimensions with the same image rendered in a smaller review panel. If you highlight text, verify that the outline still encloses the same field. Finally, repeat the source retrieval with an ordinary authorized reviewer account so the person responsible for confirming the transcription can actually read it. A useful Node.js intake lets that person see the proposed fields, the original document, the current company observation if requested, and the source of any difference.