Malaysia MyKad OCR Python SDK

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

AI extracting data from a Malaysia ID card
StructOCR engine analyzing a Malaysian Identity Card (MyKad) in real-time.

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.

1
Upload
2
Results

Drop files here or click to browse

JPG · PNG · WebP  ·  up to 500 files · max 4.5 MB each

No files selected
Need more testing? Create a free account to get 200 free credits (equals 100 National ID scans).

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

Country Tutorial

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.

Python · Passport
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

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.

Python · Passport
Country Tutorial

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.

Python · Passport
Country Tutorial

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 · Passport
Tutorial

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.

Python · Receipt
Country Tutorial

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.

Python · id-kaart
Country Tutorial

Ethiopia Fayda ID OCR Python SDK

Python Tutorial: Automate KYC in Ethiopia. Extract data from Fayda ID using StructOCR Python SDK. Supports native text.

Python · fayda id
Country Tutorial

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.

Python · občanský průkaz
Country Tutorial

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.

Python · personalausweis

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 99.9% Uptime