India Aadhaar & PAN Card OCR Python SDK

Instantly extract data from Indian Identity Documents (Aadhaar, PAN Card) using our native Python library.

James | Technical LeadUpdated 2026-06-04
AI extracting data from an Indian PAN card and Aadhaar
StructOCR engine analyzing Indian Identity Documents in real-time.

Parsing Indian ID Challenges

Indian identity documents, primarily the Aadhaar and PAN Card, pose unique OCR challenges. Accurately extracting the 12-digit Aadhaar UID or the 10-character alphanumeric Permanent Account Number (PAN), handling bilingual layouts (Hindi and English), and parsing varying print formats across physical cards and digital printouts (e-PAN/e-Aadhaar) require highly specialized computer vision models.

Why StructOCR for India

StructOCR's model is specifically trained on a massive dataset of Indian ID images, ensuring high accuracy for national id ocr extraction. The v1.4.0 Python SDK simplifies the integration process, while our Cloudflare Workers infrastructure ensures ultra-low latency processing. With just a few lines of code, you can extract structural data, including the PAN or Aadhaar mapped directly to the personal number field, to fully automate your C-KYC verification workflows.

Common Use Cases in India

  • UPI & Fintech Onboarding: Verify users for digital wallets, microlending apps, and UPI payment gateways across India.
  • Demat & Trading Accounts: Automate document parsing for retail brokerage accounts complying with strict SEBI KYC regulations.
  • Telecom eKYC: Speed up identity verification for mobile SIM card sales and broadband activations.

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

# 💰 Note: Deposit via Crypto (USDT/USDC) to automatically receive a 10% credit bonus.
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")

def scan_india_id():
    # Note: Supports JPG, PNG, WebP (Max 4.5MB)
    # Target: PAN Card (or Aadhaar)
    image_path = "india_pan_card.jpg"

    try:
        print(f"Scanning {image_path}...")
        
        # The SDK handles file upload and API communication
        # It automatically detects the specific Indian document type
        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("✅ India Extraction Successful!")
            
            # Basic Identity
            print(f"Region:      {data.get('country_code')}")
            print(f"Name:        {data.get('given_names')} {data.get('surname')}")
            
            # Critical Field: PAN or Aadhaar Number
            print(f"ID Number:   {data.get('personal_number')}")
            
            # Demographics & Family
            print(f"DOB:         {data.get('date_of_birth')}")
            
            # Father's Name is critical for PAN card verifications
            additional = data.get('additional_fields', {})
            if additional.get('fathers_name'):
                print(f"Father:      {additional.get('fathers_name')}")
            
        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_india_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

  • Bilingual Native Support: Reads Hindi (Devanagari script) and English text seamlessly, cross-verifying outputs for higher accuracy.
  • Format Validation: Automatically identifies document types and validates the 10-character PAN structure or 12-digit Aadhaar checksum.
  • Father's Name Extraction: Accurately isolates and extracts the Father's Name field, a critical requirement for Indian financial KYC.
  • Date Normalization: Standardizes varying Indian date formats into a consistent `YYYY-MM-DD` output.
  • 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 (Example for PAN Card).

{
  "success": true,
  "data": {
    "type": "national_id",
    "country_code": "IND",
    "nationality": "INDIAN",
    "document_number": "ABCDE1234F",
    "card_series": "",
    "personal_number": "ABCDE1234F",
    "surname": "SHARMA",
    "given_names": "RAHUL",
    "sex": "M",
    "date_of_birth": "1988-10-25",
    "place_of_birth": null,
    "address": null,
    "date_of_issue": null,
    "date_of_expiry": null,
    "issuing_authority": "INCOME TAX DEPARTMENT",
    "additional_fields": {
      "fathers_name": "SURESH SHARMA",
      "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 both Aadhaar and PAN Cards?

Yes, our endpoint uses a unified AI model that automatically classifies whether the uploaded image is an Aadhaar card, a PAN card, or a Voter ID, applying the correct extraction schema dynamically.

Is data stored?

No. Images are processed in-memory and deleted immediately to comply with India's Digital Personal Data Protection Act (DPDP) and global data privacy regulations.

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

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
Country Tutorial

India Aadhaar OCR with Node.js SDK

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

Node.js · National ID
Country Tutorial

Brazil CIN OCR Python SDK: Extract CPF & MRZ

Python Tutorial: Automate KYC in Brazil. Extract Portuguese text, CPF numbers, and validate TD1 MRZ from the new CIN using the StructOCR Python SDK.

Python · carteira de identidade (cin)
Country Tutorial

Nigeria NIN Slip OCR Python SDK

Python Tutorial: Automate KYC in Nigeria. Extract data from NIN Slip using StructOCR Python SDK. Supports native text.

Python · nin slip & e-id
Tutorial

Python Passport OCR API

Reliable Python Passport OCR API for high-accuracy data extraction. Upload an image for a free test! Get structured JSON output in milliseconds using our dedicated Python SDK. Eliminate errors.

Python · Passport
Country Tutorial

Colombia Passport OCR with Python SDK

Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Colombia passports with a server-side integration.

Python · Passport
Country Tutorial

UAE Emirates ID OCR Python SDK

Python Tutorial: Automate KYC in the UAE. Extract data from Emirates ID using the StructOCR Python SDK. Supports bilingual (Arabic/English) text, front/back sides, and 3-line MRZ extraction.

Python · emirates id
Country Tutorial

Thailand ID Card OCR Python SDK

Python Tutorial: Automate KYC in Thailand. Extract data from the Thai National Identity Card using StructOCR Python SDK. Supports Thai script, dual-language fields, and 13-digit Citizen ID extraction.

Python · thai id card
Country Tutorial

Tajikistan ID Card (Karta) OCR Python SDK

Python Tutorial: Automate KYC in Tajikistan. Extract data from ID Card (Karta) using StructOCR Python SDK. Supports native text and MRZ extraction.

Python · id card (karta)
Country Tutorial

US 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 US passports.

Node.js · Passport

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