Nigeria NIN Slip & e-ID OCR Python SDK
Instantly extract data and MRZ from Nigerian IDs using our native Python library.
Parsing NIN Slip Challenges
Parsing NIN Slips presents unique challenges. Firstly, the print quality on some slips can be inconsistent, leading to blurred or distorted characters. Secondly, variations in layout and design across different NIN Slip versions can complicate accurate data extraction.
Why StructOCR for Nigeria
StructOCR's model is specifically trained on a vast dataset of Nigerian NIN Slips and e-ID cards, enabling robust and accurate data extraction even with variations in print quality and layout. Our Python SDK simplifies integration into your existing systems, providing a clean and intuitive id parsing api for seamless document processing. It also fully supports parsing the Machine Readable Zone (MRZ) for secondary validation.
Common Use Cases in Nigeria
- Digital Onboarding: Verify users for Fintech apps in Nigeria.
- Telecom Registration: Automate SIM card registration with NIN Slip.
- Hotel Check-in: Speed up guest registration workflows using MRZ scans.
Python SDK Integration
Install the SDK via pip: `pip install structocr`. Then use the following code to extract personal data and MRZ fields.
Prerequisite: Python 3.6+ and `structocr` library installed.
Prefer another stack? Open the Node.js SDK + Express integration.
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_nigeria_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: NIN Slip or e-ID Card
image_path = "nigeria_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a Nigerian 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("✅ Nigeria 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')}")
# MRZ Data (Applicable for Nigerian e-ID cards)
additional = data.get('additional_fields', {})
if additional and additional.get('mrz_line_1'):
print("\n--- MRZ Data ---")
print(f"Line 1: {additional.get('mrz_line_1')}")
print(f"Line 2: {additional.get('mrz_line_2')}")
if additional.get('mrz_line_3'):
print(f"Line 3: {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_nigeria_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 English and local characters.
- •Blur Detection: Automatically rejects blurry images.
- •Fraud Check: Validates NIN Slip number format.
- •Smart Crop: Removes background noise automatically.
- •MRZ Extraction: Seamlessly parses the 3-line Machine Readable Zone (MRZ) present on Nigerian e-ID cards.
JSON Response Example
The SDK returns a Python dictionary matching this JSON structure. Note the `additional_fields` object handling the MRZ lines.
{
"success": true,
"data": {
"type": "national_id",
"country_code": "NGA",
"nationality": "NIGERIAN",
"document_number": "12345678901",
"card_series": "",
"personal_number": "12345678901",
"surname": "OKAFOR",
"given_names": "CHINEDU EMEKA",
"sex": "M",
"date_of_birth": "1990-05-15",
"place_of_birth": "LAGOS",
"address": "12 Adetokunbo Ademola Street, Victoria Island, Lagos",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"issuing_authority": "NIMC",
"additional_fields": {
"mrz_line_1": "IDNGA1234567890<<<<<<<<<<<<<<<",
"mrz_line_2": "9005153M3001014NGA<<<<<<<<<<<8",
"mrz_line_3": "OKAFOR<<CHINEDU<EMEKA<<<<<<<<<",
"tramite_number": null,
"ejemplar": null,
"phone_number": null
}
}
}Frequently Asked Questions
Does the Python SDK handle image uploads?
Yes, the SDK automatically handles base64 encoding and file uploads.
Does the API extract MRZ from Nigerian IDs?
Yes, if the uploaded image is a Nigerian e-ID card, the API automatically parses and returns the MRZ lines inside the `additional_fields` object.
Is data stored?
Only briefly. Uploaded images and results are kept for at most 24 hours for quality spot-checks, then deleted.
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
Nigeria Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Nigeria passports with a server-side integration.
Nigeria National ID OCR with Node.js SDK
Extract National Identification Number (NIN), names, dates and other visible fields from National Identity Card with the StructOCR Node.js SDK and Express.
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.
Greece Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Greece passports with a server-side integration.
Uganda National ID Card OCR Python SDK
Python Tutorial: Automate KYC in Uganda. Extract data from National ID Card using StructOCR Python SDK. Supports native text and MRZ extraction.
Côte d'Ivoire CNI (Carte Nationale d'Identité) OCR Python SDK
Python Tutorial: Automate KYC in Côte d'Ivoire. Extract French text, NNI, and validate TD1 MRZ from the ONECI CNI using StructOCR Python SDK.
Portugal Cartão de Cidadão OCR Python SDK
Python Tutorial: Automate KYC in Portugal. Extract data from Cartão de Cidadão using StructOCR Python SDK. Supports native text and MRZ extraction.
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.
Pakistan CNIC OCR Python SDK
Python Tutorial: Automate KYC in Pakistan. Extract data from CNIC using StructOCR Python SDK. Supports native text.
Philippines UMID OCR Python SDK
Python Tutorial: Automate KYC in Philippines. Extract data from UMID using StructOCR Python SDK. Supports native text.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Invoice OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR invoice API into a Lovable.dev app. No backend required — just paste a prompt and add your API key.
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 Passport OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Lovable.dev app through a secure server-side function for travel and KYC flows.
Add Receipt OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a Lovable.dev app. No backend required — just paste a prompt and add your API key.
Add VIN OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a Lovable.dev app. Build automotive and fleet tools with zero backend required.
Manual TOS Entry vs. Container OCR Automation API
Analyzing the ROI and operational efficiency of replacing manual gate checkers with an automated Container OCR API in logistics yards.
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.