South Africa Smart ID Card OCR Python SDK
Instantly extract data and MRZ from South African IDs using our native Python library.

Parsing Smart ID Card Challenges
South African Smart ID cards present unique OCR challenges. First, the Machine Readable Zone (MRZ) can suffer from printing inconsistencies leading to read errors. Second, the layout variations between different card versions require adaptive processing logic for accurate field extraction.
Why StructOCR for South Africa
Our model is specifically trained on a large dataset of South African Smart ID cards, ensuring high accuracy even with variations and imperfections. The StructOCR Python SDK simplifies integration with a clean API, making it an ideal solution for id parsing api needs. You can process images directly with a few lines of code, receiving structured data—including complete MRZ support for strict global compliance—ready for your application, which significantly aids in kyc automation.
Common Use Cases in South Africa
- Digital Onboarding: Verify users for Fintech apps in South Africa.
- Telecom Registration: Automate SIM card registration with Smart ID Card.
- Hotel Check-in: Speed up guest registration workflows.
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.
Prefer another stack? Open the Node.js SDK + Express integration.
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_south_africa_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Smart ID Card
image_path = "south_africa_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a South African 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("✅ South Africa 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)
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')}")
# Machine Readable Zone (MRZ)
additional = data.get('additional_fields', {})
if additional.get('mrz_line_1'):
print("\n--- MRZ Data ---")
print(additional.get('mrz_line_1'))
print(additional.get('mrz_line_2'))
if additional.get('mrz_line_3'):
print(additional.get('mrz_line_3'))
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_south_africa_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 Parsing: Accurately extracts and validates the Machine Readable Zone lines for cross-checking.
- •Blur Detection: Automatically rejects blurry images.
- •Fraud Check: Validates Smart ID Card 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": "ZAF",
"nationality": "RSA",
"document_number": "900101 5009 08 7",
"card_series": "",
"personal_number": "9001015009087",
"surname": "NKOSI",
"given_names": "THEMBA",
"sex": "M",
"date_of_birth": "1990-05-15",
"place_of_birth": "SOWETO",
"address": "45 Nelson Mandela Blvd, Cape Town",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"issuing_authority": "Department of Home Affairs",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "IDZAF9001015009087<<<<<<<<<<<<",
"mrz_line_2": "9005152M3001014ZAF<<<<<<<<<<<8",
"mrz_line_3": "NKOSI<<THEMBA<<<<<<<<<<<<<<<<<"
}
}
}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.
How to handle errors?
The SDK result dictionary contains a 'success' boolean and an 'error' message if failed.
You May Also Like
Related tutorials, platform guides, and comparisons
South Africa Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from South Africa passports with a server-side integration.
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.
UK Driver License OCR with Python SDK
Extract structured fields from a United Kingdom photocard driving 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.
Kenya Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Kenya passports with a server-side integration.
Sweden Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Sweden passports with a server-side integration.
Python License Plate OCR API
Python License Plate OCR SDK tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.
Mexico INE OCR API & Python SDK
Python Tutorial: Automate KYC in Mexico. Extract data from INE cards using our SDK. Upload your ID image to test the OCR engine live—no signup required. Supports native text and MRZ.
Nigeria NIN Slip OCR Python SDK
Python Tutorial: Automate KYC in Nigeria. Extract data from NIN Slip using StructOCR Python SDK. Supports native text.
Morocco CNIE OCR Python SDK
Python Tutorial: Automate KYC in Morocco. Extract data from CNIE using StructOCR Python SDK. Supports native text and MRZ extraction.
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.
Add Container OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API using the Cursor AI code editor. Build logistics and yard management 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.