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.
Live Demo: ID card scanner
No registration required. Upload a file to test the extraction.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
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
# 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
# 👉 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)
- •Uptime: 99.9% SLA
- •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?
No. Images are processed in-memory and deleted immediately to comply 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.
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.
South Africa Smart ID Card OCR Python SDK
Python Tutorial: Automate KYC in South Africa. Extract data from Smart ID Card using StructOCR Python SDK. Supports native text and MRZ extraction.
South Africa Smart ID OCR with Node.js SDK
Extract identity number, names, dates and other visible fields from South African Smart ID card with the StructOCR Node.js SDK and Express.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add National ID OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Bolt.new app. Build KYC and identity verification flows right in your browser.
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 National ID OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Lovable.dev app. Build KYC and identity verification flows with zero backend.
Add National ID OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Replit application. Build KYC and identity verification flows using Replit Agent and Secrets.
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.
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.
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.