Switzerland ID Card OCR Python SDK
Instantly extract data from Swiss Identity Cards using our native Python library.
Parsing Swiss ID Challenges
The Swiss Identity Card (Identitätskarte / Carte d'identité / Carta d'identità / Carta d'identitad) poses unique OCR challenges. Accurately parsing a document that incorporates up to four national languages (German, French, Italian, Romansh), strict security features, and a complex 3-line MRZ requires highly specialized computer vision models.
Why StructOCR for Switzerland
StructOCR's model is specifically trained on a large dataset of Swiss 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, parse the MRZ, and automate your verification workflows to meet strict FINMA regulatory standards.
Common Use Cases in Switzerland
- Crypto & Web3 Onboarding: Verify users for virtual asset service providers (VASPs) operating in the Zug Crypto Valley.
- Financial Services: Automate document parsing for Swiss banking applications ensuring FINMA-compliant KYC workflows.
- Telecom Registration: Speed up mobile SIM card registrations by instantly capturing customer identity data.
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_switzerland_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Swiss Identity Card
image_path = "switzerland_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a Swiss 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("✅ Switzerland 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')}")
# Demographics
print(f"DOB: {data.get('date_of_birth')} ({data.get('sex')})")
print(f"Birthplace: {data.get('place_of_birth')}")
# 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:
# Handle SDK or Network errors
print(f"An error occurred: {e}")
if __name__ == "__main__":
scan_switzerland_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
- •Multi-lingual Support: Seamlessly reads German, French, Italian, and Romansh characters, including umlauts (ä, ö, ü).
- •MRZ Extraction: Automatically parses the 3-line Machine Readable Zone (MRZ) on the reverse of the ID.
- •Document Number Validation: Accurately extracts the alphanumeric Swiss ID document number.
- •Date Normalization: Standardizes issue dates, expiry dates, and birth dates into a consistent `YYYY-MM-DD` format.
- •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": "CHE",
"nationality": "SCHWEIZER",
"document_number": "F12345678",
"card_series": "",
"personal_number": null,
"surname": "MÜLLER",
"given_names": "LUKAS",
"sex": "M",
"date_of_birth": "1990-05-15",
"place_of_birth": "BERN",
"address": null,
"date_of_issue": "2021-10-20",
"date_of_expiry": "2031-10-19",
"issuing_authority": "KANTON BERN",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "IDCHEF123456789<<<<<<<<<<<<<<<",
"mrz_line_2": "9005155M3110198CHE<<<<<<<<<<<4",
"mrz_line_3": "MUELLER<<LUKAS<<<<<<<<<<<<<<<<"
}
}
}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 strict Swiss Federal Act on Data Protection (FADP) and GDPR.
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
Switzerland Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Switzerland passports with a server-side integration.
Ethiopia Fayda ID OCR Python SDK
Python Tutorial: Automate KYC in Ethiopia. Extract data from Fayda ID using StructOCR Python SDK. Supports native text.
Canada Driver License OCR with Python SDK
Extract structured fields from a Canada provincial driver licence with the StructOCR Python SDK and FastAPI.
Netherlands Identiteitskaart OCR Python SDK
Python Tutorial: Automate KYC in Netherlands. Extract data from Identiteitskaart using StructOCR Python SDK. Supports native text and MRZ extraction.
Brazil Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Brazil passports with a server-side integration.
Tanzania NIDA Card OCR Python SDK
Python Tutorial: Automate KYC in Tanzania. Extract data from NIDA Card using StructOCR Python SDK. Supports native text and MRZ extraction.
Serbia Lična karta OCR Python SDK
Python Tutorial: Automate KYC in Serbia. Extract data from Lična karta using StructOCR Python SDK. Supports native text and MRZ extraction.
Romania Carte de Identitate OCR Python SDK
Python Tutorial: Automate KYC in Romania. Extract data from Carte de Identitate using StructOCR Python SDK. Supports native text, front/back sides, and MRZ extraction.
Saudi Arabia National ID & Iqama OCR Python SDK
Python Tutorial: Automate KYC in Saudi Arabia. Extract data from National IDs and Iqamas using the StructOCR Python SDK. Supports bilingual (Arabic/English) text, 10-digit ID numbers, and 3-line MRZ extraction.
Senegal Carte d'Identité CEDEAO OCR Python SDK
Python Tutorial: Automate KYC in Senegal. Extract data from Carte d'Identité CEDEAO using StructOCR Python SDK. Supports native text and MRZ extraction.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Driver's License OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API using the Cursor AI code editor. Build car rental and mobility onboarding flows rapidly.
Add HIN OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API using the Cursor AI code editor. Build marine and boat management tools rapidly.
Add Invoice OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR invoice API using the Cursor AI code editor. Build accounts payable and expense tracking tools rapidly.
Add National ID OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API using the Cursor AI code editor. Build KYC and identity verification flows rapidly.
Add Passport OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API using the Cursor AI code editor. Build travel, hospitality, and global KYC flows rapidly.
Add Receipt OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API using the Cursor AI code editor. Build expense tracking and receipt scanning tools rapidly.
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.