Mexico INE (Credencial para Votar) OCR Python SDK

Instantly extract data from Mexican IDs using our native Python library.

Steve HarringtonUpdated 2026-06-2
AI extracting data from a Mexico INE card
StructOCR engine analyzing a Mexican INE document in real-time.

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.

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.

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)
  • Uptime: 99.9% 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.
  • 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?

No. All INE card images are processed in-memory for secure KYC compliance and deleted immediately after extraction.

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

Country Tutorial

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.

Python · Passport
Country Tutorial

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.

Python · dni (dnie)
Country Tutorial

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.

Python · Passport
Country Tutorial

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.

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

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

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.

Python · deltio taftotitas
Country Tutorial

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.

Python · személyazonosító
Country Tutorial

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.

Python · ghana card
Country Tutorial

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.

Python · aadhaar & pan

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