Sri Lankan Passport OCR with Node.js SDK
Read a supported Sri Lankan passport image or PDF in a server-side Node.js SDK integration.

Extracting Data from Sri Lankan Passports
Sri Lankan passports combine printed identity fields, dates and a machine-readable zone on a security-patterned page. Capture quality, glare and perspective can make manual entry or plain text OCR difficult to use in a repeatable backend workflow.
Passport Extraction with the Node.js SDK
The StructOCR passport endpoint returns normalized passport fields from a readable Base64-encoded image or PDF. Your application can use the result to pre-fill a form or send it to a review step without maintaining its own field-parsing rules.
Common Integration Scenarios
- Travel onboarding: Pre-fill passport details before the traveller confirms them.
- Customer records: Move visible identity and expiry information into an internal review workflow.
- Document intake: Return consistent JSON to a small-volume application or operations team.
Live Demo: Passport scanner
No registration required. Upload a file to test the extraction.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
Sri Lankan Passport OCR with Node.js SDK
The official Node.js SDK reads a supported local file and calls /v1/passport. Open the TypeScript + Express tab for a server route using the same SDK method.
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.scanPassport("passport.jpg");
if (result.success) {
const data = result.data;
console.log(data.document_number || data.passport_number);
console.log(data.given_names, data.surname);
} else {
console.error(result.error);
}
}
main().catch(console.error);Technical Specs
- •Endpoint: POST /v1/passport
- •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 scan
- •Output: Structured JSON
Key Features
- •Passport fields: Returns document number, holder name, nationality and birth details when visible.
- •Validity dates: Extracts issue and expiry dates when present and readable.
- •Issuing data: Includes country code, place of birth and issuing authority when available.
- •Server-side SDK: Encodes the local file and sends the JSON request from your backend.
JSON Response Example
This sample shows the normalized fields returned for a readable Sri Lankan passport; unavailable fields can be null.
{
"success": true,
"data": {
"type": "passport",
"country_code": "LKA",
"nationality": "SRI LANKAN",
"passport_number": "P1234567",
"surname": "DOE",
"given_names": "ALEX",
"sex": "X",
"date_of_birth": "1990-01-01",
"place_of_birth": "COLOMBO",
"date_of_issue": "2024-05-10",
"date_of_expiry": "2034-05-09",
"issuing_authority": "DEPARTMENT OF IMMIGRATION AND EMIGRATION"
}
}Frequently Asked Questions
Can the API scan a PDF of a Sri Lankan passport?
Yes. The endpoint accepts a Base64-encoded JPG, PNG, WebP or PDF up to 4.5MB. Keep the API key on the server.
Does OCR replace document verification?
No. OCR extracts readable fields. Use your own review, identity and compliance controls when authenticity or eligibility decisions are required.
You May Also Like
Related tutorials, platform guides, and comparisons
Sri Lankan Passport OCR with Python SDK
Use the StructOCR Python SDK and FastAPI to extract visible identity, validity and MRZ fields from Sri Lankan passports.
Switzerland Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Switzerland passports.
Thailand Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Thailand passports.
Tunisia Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Tunisia passports.
Tanzania Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Tanzania passports.
New Zealand Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from New Zealand passports.
Estonia Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Estonia passports.
South Africa Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from South Africa passports.
Tanzania Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Tanzania passports with a server-side integration.
Tajikistan Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Tajikistan passports with a server-side integration.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Passport OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Bolt.new app. Build travel, hospitality, and global KYC flows right in your browser.
Add Passport OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API using the Cursor AI code editor. Build travel, hospitality, and global KYC flows rapidly.
Extracting ECR Status & File Numbers: Generic OCR vs. StructOCR Indian Passport API
Learn why generic text extractors fail to capture critical Indian KYC fields like ECR status and File Numbers, and how a specialized API structures this data automatically.
Heavy KYC SDKs vs. StructOCR Passport API for Mobile Apps
Discover why modern app developers are abandoning bulky on-device OCR SDKs in favor of lightweight, edge-deployed Passport APIs.
Add Passport OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Lovable.dev app through a secure server-side function for travel and KYC flows.
Add Passport OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Replit application. Build travel, hospitality, and global KYC flows using Replit Agent and Secrets.
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.