India Aadhaar & PAN Card OCR Python SDK
Instantly extract data from Indian Identity Documents (Aadhaar, PAN Card) using our native Python library.
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.
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)
- •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
- •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?
Only briefly. Uploaded images and results are kept for at most 24 hours for quality spot-checks, then deleted, which helps 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
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.
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.
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.
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 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 seconds using our dedicated Python SDK. Eliminate errors.
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.
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.
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.
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.
Ukraine Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Ukraine passports with a server-side integration.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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.
Add Passport OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a v0 by Vercel app through a secure Next.js server route.
Add Receipt OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a v0 by Vercel app. Build expense tracking and receipt scanning tools right in your browser.
Add VIN OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a v0 by Vercel app. Build automotive and fleet tools with zero backend.
VIN Barcode Scanner vs. VIN OCR API: Which is Better for Mobile Apps?
Deciding between local VIN barcode scanners and cloud-based VIN OCR API for your mobile app? Learn why OCR is the required fallback for damaged or chassis-stamped VINs.
Apple Vision Framework / ML Kit vs. StructOCR VIN API
Why generic on-device text recognition frameworks fail at decoding VINs, and when to switch to a specialized automotive API.
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.