Indonesia KTP (e-KTP) OCR Python SDK
Instantly extract data from Indonesian IDs using our native Python library.
Parsing KTP (e-KTP) Challenges
Indonesian KTPs present several OCR challenges. Firstly, inconsistencies in formatting and layout across different regions are common. Secondly, the presence of native Bahasa Indonesia text combined with varying print quality makes accurate text recognition difficult.
Why StructOCR for Indonesia
Our model is specifically trained on a large dataset of Indonesian KTPs, addressing layout variations and native text recognition, making it ideal for id card parsing tasks. The Python SDK simplifies integration by providing a straightforward API for efficient information parsing, allowing you to process images with just a few lines of code.
Common Use Cases in Indonesia
- Digital Onboarding: Verify users for Fintech apps in Indonesia.
- Telecom Registration: Automate SIM card registration with KTP (e-KTP).
- Hotel Check-in: Speed up guest registration workflows.
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
# Get 200 free credits:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_indonesia_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: KTP (e-KTP)
image_path = "indonesia_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
# It automatically detects that this is a Indonesian 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("✅ Indonesia 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')}")
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_indonesia_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 KTP (e-KTP) 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": "IDN",
"nationality": "WNI",
"document_number": "3171234567890001",
"card_series": "",
"personal_number": "3171234567890001",
"surname": "SANTOSO",
"given_names": "BUDI",
"sex": "M",
"date_of_birth": "1990-05-15",
"place_of_birth": "JAKARTA",
"address": "Jl. Jend. Sudirman No. 5, Jakarta Pusat",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"issuing_authority": "Kabupaten Bogor"
}
}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.
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
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.
Indonesia KTP OCR with Node.js SDK
Extract NIK, names, dates and other visible fields from Kartu Tanda Penduduk (KTP) with the StructOCR Node.js SDK and Express.
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.
Tajikistan ID Card (Karta) OCR Python SDK
Python Tutorial: Automate KYC in Tajikistan. Extract data from ID Card (Karta) using StructOCR Python SDK. Supports native text and MRZ extraction.
Thailand ID Card OCR Python SDK
Python Tutorial: Automate KYC in Thailand. Extract data from the Thai National Identity Card using StructOCR Python SDK. Supports Thai script, dual-language fields, and 13-digit Citizen ID extraction.
Poland Dowód Osobisty OCR Python SDK
Python Tutorial: Automate KYC in Poland. Extract data and MRZ from Dowód Osobisty using StructOCR Python SDK. Supports native text.
Uzbekistan ID Karta OCR Python SDK
Python Tutorial: Automate KYC in Uzbekistan. Extract data from ID Karta using StructOCR Python SDK. Supports native text and MRZ parsing.
Vietnam CCCD OCR Python SDK
Python Tutorial: Automate KYC in Vietnam. Extract data from the Vietnamese Identity Card (Căn cước công dân / CCCD) using StructOCR Python SDK. Supports native text, diacritics, and MRZ extraction.
Go Passport OCR API
Upload an image for a free test! Extract passport data via a simple REST API in Go. Get high-accuracy, ICAO-compliant JSON output from noisy images. Eliminate manual entry errors.
C# Passport OCR API
Upload an image for a free test! High-accuracy C# Passport OCR API for parsing MRZ data. Get structured JSON output from passport images. Eliminate Tesseract errors and manual entry.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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 Passport OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a v0 by Vercel app through a secure Next.js server route.
Add Receipt OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR receipt API into a v0 by Vercel app. Build expense tracking and receipt scanning tools right in your browser.
Add VIN OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR VIN scanner API into a v0 by Vercel app. Build automotive and fleet tools with zero backend.
VIN Barcode Scanner vs. VIN OCR API: Which is Better for Mobile Apps?
Deciding between local VIN barcode scanners and cloud-based VIN OCR API for your mobile app? Learn why OCR is the required fallback for damaged or chassis-stamped VINs.
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.
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.