Mexico INE Credencial OCR Python SDK
Instantly extract data from Mexican IDs using our native Python library.

Parsing INE Credencial Challenges
Parsing INE Credenciales presents several challenges. Firstly, variations in print quality, particularly on older cards, can hinder accurate text recognition. Secondly, inconsistencies in layout and formatting across different INE Credencial versions demand robust adaptation from OCR solutions.
Why StructOCR for Mexico
StructOCR's model is specifically trained on a vast dataset of Mexican INE Credenciales, ensuring high accuracy and reliability. Our Python SDK provides a simple and intuitive interface, enabling seamless integration into your existing applications with minimal coding effort. We abstract away the complexity of the OCR process, allowing you to focus on your core business logic.
Common Use Cases in Mexico
- Digital Onboarding: Verify users for Fintech apps in Mexico.
- Telecom Registration: Automate SIM card registration with INE Credencial.
- Hotel Check-in: Speed up guest registration workflows.
Python SDK Integration
Install the SDK via pip: `pip install structocr`. Then use the following code.
Prerequisite: Python 3.6+ and `structocr` library installed.
from structocr import StructOCR
# 💰 Save 30%+ vs competitors. Get 200 free requests instantly:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_mexico_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: INE Credencial
image_path = "mexico_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a Mexican 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("✅ Mexico Extraction Successful!")
# Basic Identity
print(f"Region: {data.get('country_code')} (Series: {data.get('card_series')})")
print(f"Name: {data.get('given_names')} {data.get('surname')}")
print(f"ID Number: {data.get('document_number')}")
# Critical Field: Personal Identity Number (CNP/CPF/NIN)
print(f"Personal #: {data.get('personal_number')}")
# Demographics
print(f"DOB: {data.get('date_of_birth')} ({data.get('sex')})")
print(f"Address: {data.get('address')}")
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_mexico_id()Technical Specs
- •Latency: < 5s (Average)
- •Uptime: 98.5% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (Max 4.5MB)
- •Output: JSON (Structured Data)
Key Features
- •Native Script Support: Reads English and local characters.
- •Blur Detection: Automatically rejects blurry images.
- •Fraud Check: Validates INE Credencial number format.
- •Smart Crop: Removes background noise automatically.
JSON Response Example
The SDK returns a Python dictionary matching this JSON structure.
{
"success": true,
"data": {
"type": "national_id",
"country_code": "MEX",
"nationality": "Mexican",
"document_number": "HEGRJL99082909H100",
"card_series": null,
"personal_number": "HEGJ990829HDFRRN01",
"surname": "HERNÁNDEZ GARCÍA",
"given_names": "JOSÉ LUIS",
"sex": "M",
"date_of_birth": "1999-08-29",
"place_of_birth": null,
"address": "AV PASEO DE LA REFORMA 222\nCOL JUAREZ 06600\nCUAUHTEMOC, CDMX",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-12-31",
"issuing_authority": "INSTITUTO NACIONAL ELECTORAL"
}
}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.
How to handle errors?
The SDK result dictionary contains a 'success' boolean and an 'error' message if failed.
More OCR Tutorials
Python National ID OCR API
High-accuracy National ID OCR for Python. Get structured JSON output via our dedicated Python SDK. Automate KYC and data entry with 99%+ accuracy.
Python Driver's License OCR API
Extract driver's license data with our high-accuracy Python SDK. Get structured JSON output in seconds, eliminating manual entry and Tesseract errors.
Python Invoice OCR API
High-accuracy Invoice OCR API for Python. Get structured JSON output with line items, totals, and merchant data. Eliminate Tesseract errors with our Python SDK.
Python Passport OCR API
Reliable Python Passport OCR API for high-accuracy data extraction. Get structured JSON output in milliseconds using our dedicated Python SDK. Eliminate errors.
Precise Data Extraction and Seamless
Integration with AI-powered OCR API.
Empower your solutions with automated data extraction by
integrating best-in class StructOCR via API seamlessly.
No credit card required • Full API access included