Egypt National ID OCR Python SDK

Instantly extract data from Egyptian IDs. Test our ID OCR engine live for free below.

AI ID OCR engine extracting data from an Egypt ID card
StructOCR engine analyzing an Egyptian document in real-time.

Parsing National ID Challenges

1. Dual-Language Script: Egyptian IDs contain both right-to-left Arabic script for names and addresses, and left-to-right numerals. Standard OCR models often fail to correctly parse this mixed-script layout. 2. Encoded Data & Quality: The 14-digit National ID number embeds the date of birth, governorate, and gender. Validating this requires specific logic, not just text extraction. Furthermore, physical card wear, tear, and variable print quality can degrade accuracy.

Why StructOCR for Egypt

Our AI model is specifically pre-trained on tens of thousands of Egyptian National ID cards, ensuring exceptional accuracy with Arabic script and complex layouts for national id ocr. The Python SDK eliminates boilerplate code by handling API requests and image encoding, allowing you to seamlessly implement KYC automation into your application in minutes. Want to see it in action? Use the live demo widget below to test our ID OCR engine for free. For production usage, view our flexible pricing.

Common Use Cases in Egypt

  • Digital Onboarding: Verify users for Fintech apps, digital banks, and online services in Egypt.
  • Telecom Registration: Automate SIM card registration and user verification with National ID data.
  • Hotel Check-in: Speed up guest registration and compliance workflows for the hospitality industry.

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

Ready to use this in production? Get 20 free API calls — no credit card needed.

Get 20 Free API Calls →

Python SDK Integration

Install the SDK via pip: `pip install structocr`. Then use the following code to connect to our ID OCR API. Prefer raw HTTP requests? Read the official API documentation.

Prerequisite: Python 3.6+ and `structocr` library installed.

PYTHON EXAMPLE
from structocr import StructOCR

# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")

def scan_egypt_id():
    # Target: National ID
    image_path = "egypt_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("✅ Egypt 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
            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:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    scan_egypt_id()

Technical Specs

  • Latency: < 4s (Average)
  • Uptime: 99.9% SLA
  • Security: AES-256 Encryption & SOC2 Type II Compliant
  • Input: JPG, PNG, WebP (Max 5MB)
  • Output: JSON (Structured Data)

Key Features

  • Arabic & English Support: Accurately reads native Arabic script and transliterated English names.
  • Blur & Glare Detection: Automatically rejects low-quality images to ensure data integrity.
  • National ID Number Validation: Cross-validates the encoded date of birth and gender within the 14-digit ID number.
  • Smart Crop: Intelligently isolates the ID card from any background, improving focus and accuracy.

JSON Response Example

The SDK returns a Python dictionary matching this JSON structure. Note the corrected dates for data consistency.

{
  "success": true,
  "data": {
    "type": "national_id",
    "country_code": "EGY",
    "nationality": "EGYPTIAN",
    "document_number": "JA1234567",
    "card_series": "null",
    "personal_number": "29101011200078",
    "surname": "محمد",
    "given_names": "أحمد حسن",
    "sex": "M",
    "date_of_birth": "1991-01-01",
    "place_of_birth": "null",
    "address": "١٥ ميدان التحرير، القاهرة",
    "date_of_issue": "null",
    "date_of_expiry": "null",
    "issuing_authority": "null"
  }
}

Frequently Asked Questions

Can I test the ID OCR API for free?

Yes! You can use the live testing widget on this page to upload an ID image and see the extracted JSON data instantly. To get your own API key with 20 free credits, visit our registration page.

Does the Python SDK handle image uploads?

Yes, the SDK automatically handles file reading, base64 encoding, and the multipart/form-data upload process. You only need to provide the file path.

Is our customers' data stored on your servers?

No. Images and extracted data are processed in-memory and permanently deleted immediately after the API response is sent. We are a stateless processing API.

More OCR Tutorials

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