Mexico INE (Credencial para Votar) OCR Python SDK
Instantly extract data from Mexican IDs using our native Python library.
Parsing INE (Credencial para Votar) Challenges
In Mexico, the National ID is commonly known as the INE card (Instituto Nacional Electoral) or Credencial para Votar. Parsing these INE cards 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 versions demand robust adaptation from OCR solutions.
Why StructOCR for Mexico
StructOCR's model is specifically trained on a vast dataset of Mexican INE cards, ensuring high accuracy and reliability for national id ocr. Our Python SDK provides a simple and intuitive interface, enabling seamless integration into your existing applications with minimal coding effort for KYC automation. We abstract away the complexity of the OCR process. Explore our flexible pricing to start testing with free credits today.
Common Use Cases in Mexico
- Digital Onboarding: Verify users for Fintech apps in Mexico.
- Telecom Registration: Automate SIM card registration with INE cards.
- 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
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_mexico_id():
# Target: Mexico INE Credencial
image_path = "mexico_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
result = client.scan_national_id(image_path)
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/CURP)
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')}")
# MRZ Extraction
additional = data.get('additional_fields', {})
if additional.get('mrz_line_1'):
print("\n🔍 MRZ Data Found:")
print(additional.get('mrz_line_1'))
print(additional.get('mrz_line_2'))
print(additional.get('mrz_line_3') or "")
else:
print(f"❌ Extraction Failed: {result.get('error')}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
scan_mexico_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
- •Native Script Support: Reads English and local characters.
- •MRZ Extraction: Automatically parses Machine Readable Zone (MRZ) lines for enhanced data validation and identity verification.
- •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": "133418162",
"card_series": null,
"personal_number": "1519293595265",
"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",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "IDMEXHEGRJL99082909H100<<<<<",
"mrz_line_2": "9908295M3012314MEX<<<<<<<<<<<8",
"mrz_line_3": "HERNANDEZ<GARCIA<<JOSE<LUIS<<<"
}
}
}Frequently Asked Questions
Does the SDK automatically detect Mexican INE cards?
Yes, the SDK handles image uploads and automatically routes the document to our specialized Mexico INE parser. No manual region selection is required.
Is the Credencial para Votar data stored on your servers?
Only briefly. Uploaded images and results are kept for at most 24 hours for quality spot-checks, then deleted.
Can I use raw HTTP requests instead of the Python SDK?
Absolutely. You can integrate directly with our REST API for INE extraction. Refer to our National ID API docs at: National ID Card OCR API documentation.
You May Also Like
Related tutorials, platform guides, and comparisons
Mexico Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Mexico passports with a server-side integration.
Spain DNI (DNIe) OCR Python SDK
Python Tutorial: Automate KYC in Spain. Extract data from DNI (DNIe) using StructOCR Python SDK. Supports native text and MRZ extraction.
Estonia Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Estonia passports with a server-side integration.
Poland Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Poland passports with a server-side integration.
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.
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.
Greece Deltio Taftotitas OCR Python SDK
Python Tutorial: Automate KYC in Greece. Extract dual-script data from Deltio Taftotitas and validate TD1 MRZ using StructOCR Python SDK.
Hungary Személyazonosító OCR Python SDK
Python Tutorial: Automate KYC in Hungary. Extract data from Személyazonosító and validate TD1 MRZ using StructOCR Python SDK. Supports native Hungarian text and accents.
Ghana Ghana Card OCR Python SDK
Python Tutorial: Automate KYC in Ghana. Extract data, Personal ID Number, and validate TD1 MRZ from Ghana Card using StructOCR Python SDK.
India Aadhaar & PAN Card OCR Python SDK
Python Tutorial: Automate KYC in India. Extract data from Indian Aadhaar and PAN Cards using StructOCR Python SDK. Supports Hindi/English parsing and secure format validation.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add HIN OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API into a v0 by Vercel app. Build marine and boat management tools with zero backend.
Add Invoice OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR invoice API into a v0 by Vercel app. Build accounts payable and expense tracking tools with zero backend.
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.
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.