Hong Kong HKID OCR API with Node.js

Extract the HKID number, names, and dates from the Hong Kong Identity Card (HKID) with the StructOCR Node.js SDK and a server-side integration.

Working with the Hong Kong Identity Card (HKID)

The smart HKID shows the holder’s name in English and Chinese, the HKID number with its check character in brackets, and date of birth. Re-keying these values is slow, and generic OCR still leaves your team to map each text fragment to the right field.

Structured Extraction for Your Backend

The National ID OCR API returns the HKID number, names, dates, and address when they are printed on the submitted side of the card. Test it with the free ID card scanner.

Common Integration Scenarios

  • Customer onboarding: Pre-fill identity fields from the Hong Kong Identity Card (HKID) before the customer confirms them.
  • Account operations: Reduce manual transcription when staff enter identity data.
  • Document review: Store normalized output next to your own review decision.
Need more testing? Create a free account to get 200 free credits (equals 100 National ID scans).

Hong Kong HKID OCR API with Node.js

The official Node.js SDK reads a local file and calls /v1/national-id from your backend.

Prerequisite: `npm install structocr`; set the server-side `STRUCTOCR_API_KEY` environment variable.

Prefer another stack? Open the Python SDK + FastAPI integration.

const StructOCR = require("structocr");

const client = new StructOCR(process.env.STRUCTOCR_API_KEY);

async function main() {
  const result = await client.scanNationalId("id-card.jpg");
  if (result.success) {
    const data = result.data;
    console.log(data.document_number);
    console.log(data.given_names, data.surname);
  } else {
    console.error(result.error);
  }
}

main().catch(console.error);

Technical Specs

  • •Endpoint: POST /v1/national-id
  • •Input: Base64-encoded JPG, PNG, WebP, or PDF in JSON (Max 4.5MB)
  • •Authentication: Server-side x-api-key header handled by the SDK
  • •Cost: 2 credits per successful scan; failed requests are not billed
  • •Output: Structured JSON

Key Features

  • •Local document: Handles the Hong Kong Identity Card (HKID) as a national identity document.
  • •Identifier output: Returns the HKID number when visible.
  • •Normalized names and dates: Consistent JSON keys across countries.
  • •Server integration: The API key stays on your backend.

JSON Response Example

Fictional values showing the normalized shape for a readable Hong Kong Identity Card (HKID); unavailable fields are null.

{
  "success": true,
  "data": {
    "type": "national_id",
    "country_code": "HKG",
    "document_number": "A000000(0)",
    "personal_number": null,
    "surname": "DOE",
    "given_names": "ALEX",
    "sex": null,
    "date_of_birth": "1990-01-01",
    "place_of_birth": null,
    "date_of_issue": null,
    "date_of_expiry": null,
    "issuing_authority": null,
    "address": null,
    "additional_fields": {}
  }
}

Frequently Asked Questions

Does the API validate the HKID number?

It extracts the number as printed. Database checks and authenticity verification require official channels or your own review.

Which inputs are supported?

JSON with a Base64-encoded JPG, PNG, WebP, or PDF up to 4.5MB; the SDK handles encoding.

Is there a version for the other SDK language?

Yes. A paired Python version of this tutorial covers the same document.

You May Also Like

Related tutorials, platform guides, and comparisons

Country Tutorial

Hong Kong HKID OCR API with Python

Extract the HKID number, names, and dates from the Hong Kong Identity Card (HKID) with the StructOCR Python SDK and a server-side integration.

Python · National ID
Country Tutorial

Taiwan National ID Card OCR API with Node.js

Extract the ID number, names, and dates from the Taiwan National Identification Card with the StructOCR Node.js SDK and a server-side integration.

Node.js · National ID
Country Tutorial

Honduras DNI OCR API with Node.js

Extract the DNI number, names, and dates from the Honduras Documento Nacional de Identificación (DNI) with the StructOCR Node.js SDK and a server-side integration.

Node.js · National ID
Country Tutorial

Malaysia MyKad OCR with Node.js SDK

Extract identity number, names, dates and other visible fields from MyKad with the StructOCR Node.js SDK and Express.

Node.js · National ID
Country Tutorial

UAE Emirates ID OCR with Node.js SDK

Extract Emirates ID number, names, dates and other visible fields from Emirates ID with the StructOCR Node.js SDK and Express.

Node.js · National ID
Country Tutorial

Paraguay Cédula OCR API with Node.js

Extract the cédula number, names, and dates from the Paraguay Cédula de Identidad Civil with the StructOCR Node.js SDK and a server-side integration.

Node.js · National ID
Tutorial

Node.js National ID OCR API

Extract National ID data with our Node.js SDK. Upload an image for a free test! Get clean, validated JSON output from any ID card image. Integrate KYC in minutes.

Node.js · National ID
Country Tutorial

Côte d'Ivoire CNI (Carte Nationale d'Identité) OCR Python SDK

Python Tutorial: Automate KYC in Côte d'Ivoire. Extract French text, NNI, and validate TD1 MRZ from the ONECI CNI using StructOCR Python SDK.

Python · National ID
Country Tutorial

Bangladesh Smart NID OCR Python SDK

Python Tutorial: Automate KYC in Bangladesh. Extract complex Bengali text and decode 2D barcodes from Smart NIDs using StructOCR Python SDK.

Python · National ID
Country Tutorial

France Carte Nationale d'Identité OCR Python SDK

Python Tutorial: Automate KYC in France. Extract data from Carte Nationale d'Identité and validate TD1/TD2 MRZ using StructOCR Python SDK. Supports native text.

Python · National ID

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 No Credit Card