Malaysia MyKad OCR Python SDK
Instantly extract data from Malaysian Identity Cards (MyKad) using our native Python library.

Parsing MyKad Challenges
The Malaysian Identity Card (MyKad) poses unique OCR challenges. Accurately extracting the 12-digit National Registration Identity Card (NRIC) number, parsing highly detailed multi-line addresses (including Jalan, Taman, and Poskod), and handling various card backgrounds require highly specialized computer vision models.
Why StructOCR for Malaysia
StructOCR's model is specifically trained on a large dataset of Malaysian ID images, ensuring high accuracy for national id ocr extraction. The Python SDK simplifies the integration process with just a few lines of code, allowing you to instantly extract structural data, including the NRIC mapped to the personal number field, and automate your verification workflows.
Common Use Cases in Malaysia
- E-Wallet & Fintech Onboarding: Verify users for digital wallets, microlending apps, and payment gateways operating in Malaysia.
- Banking Account Opening: Automate eKYC processes for digital banks complying with Bank Negara Malaysia (BNM) regulations.
- Telecom SIM Registration: Speed up mobile SIM card registrations by instantly capturing customer identity data.
Live Demo: ID card 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
Python SDK Integration
Install the SDK via pip: `pip install structocr`. Then use the following code.
Prerequisite: Python 3.6+ and `structocr` library installed.
Prefer another stack? Open the Node.js SDK + Express integration.
from structocr import StructOCR
# 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_malaysia_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Malaysian Identity Card (MyKad)
image_path = "malaysia_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a Malaysian document
result = client.scan_national_id(image_path)
# Check success flag (SDK returns a dict matching the JSON response)
if result.get('success'):
data = result['data']
print("✅ Malaysia Extraction Successful!")
# Basic Identity
print(f"Region: {data.get('country_code')}")
print(f"Name: {data.get('given_names')} {data.get('surname')}")
# Critical Field: NRIC
print(f"NRIC: {data.get('personal_number')}")
# Demographics
print(f"DOB: {data.get('date_of_birth')} ({data.get('sex')})")
print(f"Address: {data.get('address')}")
# Additional Fields
additional = data.get('additional_fields', {})
if additional.get('mrz_line_1'):
print("\n🔍 Additional Data Found.")
else:
print(f"❌ Extraction Failed: {result.get('error')}")
except Exception as e:
# Handle SDK or Network errors
print(f"An error occurred: {e}")
if __name__ == "__main__":
scan_malaysia_id()Technical Specs
- •Latency: < 4s (Average)
- •Uptime: 99.9% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (Max 4.5MB)
- •Output: JSON (Structured Data)
Key Features
- •NRIC Extraction: Automatically extracts and structure-validates the 12-digit Malaysian National Registration Identity Card number.
- •Multi-line Address Support: Capable of reconstructing complex multi-line Malaysian addresses including house numbers, Jalan, Taman, Poskod, and State.
- •Date Normalization: Extracts and standardizes birth dates embedded within the NRIC into a consistent `YYYY-MM-DD` format.
- •Smart Crop & Blur Detection: Rejects blurry images and removes background noise automatically to ensure high precision.
JSON Response Example
The SDK returns a Python dictionary matching this JSON structure.
{
"success": true,
"data": {
"type": "national_id",
"country_code": "MYS",
"nationality": "WARGANEGARA",
"document_number": "12345678",
"card_series": "",
"personal_number": "900101-14-5678",
"surname": "ABDULLAH",
"given_names": "AHMAD BIN",
"sex": "M",
"date_of_birth": "1990-01-01",
"place_of_birth": "KUALA LUMPUR",
"address": "NO 12 JALAN MERDEKA 1, TAMAN MERDEKA, 50000 KUALA LUMPUR, WILAYAH PERSEKUTUAN",
"date_of_issue": "2012-05-15",
"date_of_expiry": null,
"issuing_authority": "JABATAN PENDAFTARAN NEGARA",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": null,
"mrz_line_2": null,
"mrz_line_3": null
}
}
}Frequently Asked Questions
Does the Python SDK handle image uploads?
Yes, the SDK automatically handles base64 encoding and file uploads.
Is data stored?
No. Images are processed in-memory and deleted immediately to comply with Malaysia's Personal Data Protection Act (PDPA) and global data protection laws.
How to handle errors?
The SDK result dictionary contains a 'success' boolean and an 'error' code (e.g., FILE_TOO_LARGE) if failed.
You May Also Like
Related tutorials, platform guides, and comparisons
Malaysia Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Malaysia passports with a server-side integration.
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.
Vietnam Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Vietnam 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.
Indian Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Indian passports with a server-side integration.
Python Receipt OCR API SDK
Tutorial: Extract merchants, line items, and totals from receipts using the StructOCR Python SDK. Upload an image for a free test! Ideal for fintech ETL pipelines, AI accounting, and Pandas dataframes.
Estonia ID-kaart OCR Python SDK
Python Tutorial: Automate KYC in Estonia. Extract data from the Estonian Identity Card (ID-kaart) using StructOCR Python SDK. Supports native text, Isikukood, and MRZ extraction.
Ethiopia Fayda ID OCR Python SDK
Python Tutorial: Automate KYC in Ethiopia. Extract data from Fayda ID using StructOCR Python SDK. Supports native text.
Czech Republic Občanský průkaz OCR Python SDK
Python Tutorial: Automate KYC in the Czech Republic. Extract Czech text with diacritics, Rodné číslo, and validate TD1 MRZ from Občanský průkaz.
Germany Personalausweis OCR Python SDK
Python Tutorial: Automate KYC in Germany. Extract data from Personalausweis and validate TD1 MRZ using StructOCR Python SDK. Supports native German text.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add National ID OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Bolt.new app. Build KYC and identity verification flows right in your browser.
Add National ID OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API using the Cursor AI code editor. Build KYC and identity verification flows rapidly.
Add National ID OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Lovable.dev app. Build KYC and identity verification flows with zero backend.
Add National ID OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Replit application. Build KYC and identity verification flows using Replit Agent and Secrets.
Add National ID OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a v0 by Vercel app. Build KYC and identity verification flows with zero backend.
Tesseract OCR vs. StructOCR API for ISO 6346 Container Numbers
A technical comparison for developers evaluating open-source Tesseract vs. a dedicated cloud API for extracting shipping container numbers.
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.