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.
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
# Get 200 free credits:
# 👉 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)
- •Availability: Served from Cloudflare's global edge network
- •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?
Only briefly. Uploaded images and results are kept for at most 24 hours for quality spot-checks, then deleted, which helps 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 Driver's License OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Replit application. Build car rental and mobility onboarding flows using Replit Agent and Secrets.
Add HIN OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API into a Replit application. Build marine and boat management tools using Replit Agent and Secrets.
Add Invoice OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR invoice API into a Replit application. Build accounts payable and expense tracking tools using Replit Agent and Secrets.
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 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.
Add Receipt OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a Replit application. Build expense tracking and receipt scanning tools 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.