Italy Carta di Identità OCR Python SDK
Instantly extract data from Italian IDs (CIE) using our native Python library.
Parsing Carta di Identità Challenges
The Italian Carta di Identità, particularly the newer electronic version (CIE) and the legacy paper formats, poses unique OCR challenges. Accurately extracting the complex Codice Fiscale (tax code), multi-line addresses, and scanning the 3-line MRZ on the reverse side require highly specialized computer vision models.
Why StructOCR for Italy
StructOCR's model is specifically trained on a large dataset of Italian ID images, ensuring high accuracy for national id ocr extraction. The Python SDK simplifies the integration process with just a few lines of code, allowing you to instantly extract structural data, including the Codice Fiscale mapped to the personal number field, and automate your verification workflows.
Common Use Cases in Italy
- Digital Onboarding: Verify users for Fintech apps and banking services in Italy.
- SPID Integration: Automate document parsing for Italian digital identity frameworks.
- Hotel Check-in: Speed up guest registration workflows complying with Italian security laws.
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
# Get 200 free credits:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_italy_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Carta di Identità (CIE)
image_path = "italy_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is an Italian 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("✅ Italy Extraction Successful!")
# Basic Identity
print(f"Region: {data.get('country_code')}")
print(f"Name: {data.get('given_names')} {data.get('surname')}")
print(f"ID Number: {data.get('document_number')}")
# Critical Field: Codice Fiscale
print(f"Codice Fisc: {data.get('personal_number')}")
# Demographics
print(f"DOB: {data.get('date_of_birth')} ({data.get('sex')})")
print(f"Address: {data.get('address')}")
# MRZ Extraction (Present on the back of Italian CIE)
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:
# Handle SDK or Network errors
print(f"An error occurred: {e}")
if __name__ == "__main__":
scan_italy_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 Italian special characters seamlessly.
- •MRZ Extraction: Automatically parses the 3-line Machine Readable Zone (MRZ) on the reverse of the electronic ID.
- •Codice Fiscale Extraction: Automatically extracts and validates the Italian tax code layout.
- •Multi-line Address Support: Capable of reconstructing complex multi-line addresses common on Italian cards.
- •Smart Crop & Blur Detection: Rejects blurry images and 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": "ITA",
"nationality": "ITALIANA",
"document_number": "CA00000AA",
"card_series": "",
"personal_number": "RSSMRA80A01H501U",
"surname": "ROSSI",
"given_names": "MARIO",
"sex": "M",
"date_of_birth": "1980-01-01",
"place_of_birth": "ROMA",
"address": "VIA ROMA 1, 00100 ROMA (RM)",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"issuing_authority": "COMUNE DI ROMA",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "I<ITACA00000AA6<<<<<<<<<<<<<<<",
"mrz_line_2": "8001014M3001012ITA<<<<<<<<<<<4",
"mrz_line_3": "ROSSI<<MARIO<<<<<<<<<<<<<<<<<<"
}
}
}Frequently Asked Questions
Does the Python SDK handle image uploads?
Yes, the SDK automatically handles base64 encoding and file uploads.
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 GDPR and Italian data protection laws.
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
Italy Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Italy passports with a server-side integration.
Indonesia Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Indonesia passports with a server-side integration.
Philippines Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Philippines passports with a server-side integration.
Colombia Cédula OCR Python SDK
Python Tutorial: Automate KYC in Colombia. Extract data from the Colombian Cédula de Ciudadanía using StructOCR Python SDK. Supports NUIP extraction and complex address parsing.
Chile Cédula OCR Python SDK
Python Tutorial: Automate KYC in Chile. Extract data from the Chilean Cédula de Identidad using StructOCR Python SDK. Supports RUN/RUT extraction and native Spanish text parsing.
UK Driver License OCR with Python SDK
Extract structured fields from a United Kingdom photocard driving licence with the StructOCR Python SDK and FastAPI.
Belgium eID OCR Python SDK
Python Tutorial: Automate KYC in Belgium. Extract data from Electronic Identity Card (eID) using StructOCR Python SDK. Supports native text, National Register Number, and MRZ extraction.
Algeria CNIBE (Biometric ID) OCR Python SDK
Python Tutorial: Automate KYC in Algeria. Extract bilingual text and validate TD1 MRZ from CNIBE (Biometric ID) using StructOCR Python SDK.
Bangladesh Smart NID OCR Python SDK
Python Tutorial: Automate KYC in Bangladesh. Extract complex Bengali text and decode 2D barcodes from Smart NIDs using StructOCR Python SDK.
Argentina DNI OCR Python SDK
Python Tutorial: Automate KYC in Argentina. Extract Spanish text, CUIL/CUIT, and validate TD1 MRZ from DNI using StructOCR Python SDK.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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.
AWS Textract vs. StructOCR API for Indian Passport Back Page Extraction
Why generic OCR fails at parsing the back page of Indian passports, and how a dedicated KYC API instantly extracts structured addresses, PIN codes, and family details.
AWS Textract & Google Vision vs. StructOCR Passport API
How AWS Textract AnalyzeID, Google Cloud Vision OCR, and the StructOCR Passport API differ for passport data, quoting each vendor’s own documentation.
Add Container OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API into a Bolt.new app. Build logistics and yard management tools right in your browser.
Add Driver's License OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Bolt.new app. Build car rental and mobility onboarding flows right in your browser.
Add HIN OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API into a Bolt.new app. Build marine and boat management tools right in your browser.
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.