Spain Passport OCR with the StructOCR Python SDK
Install the official Python SDK, extract validated Spain passport fields, and add the same workflow to a FastAPI service.

Challenges with Spain Passport Verification
Extracting accurate data from Spanish passports can be a complex task. Security features, intricate background patterns, and laminate glare often obscure critical information. Manual entry is prone to errors and delays. Our core passport data extraction api is specifically engineered to overcome these optical obstacles, ensuring high accuracy without relying on heavy client-side processing.
Why Use Our Passport Extraction API
Our engine excels in processing Spanish identity documents with unparalleled accuracy. Delivered as a pure REST API deployed on a global edge network, it integrates seamlessly into your existing stack regardless of the framework. Whether you are building a fintech identity verification software solution or a travel booking platform, our passport extraction API handles raw PDFs, image files, Base64 strings, or direct URLs to provide reliable, structured JSON results instantly. For the fastest Python integration, install the official StructOCR SDK and see the Python SDK documentation.
Built for High-Compliance Industries
- Travel & Aviation: Our technology provides a seamless verification solution for travel, significantly speeding up check-in by using the API to validate Spanish passport details in under a second.
- Financial Services: Leverage our robust fintech identity verification software to automate KYC onboarding, utilizing direct Base64 uploads to maintain strict data compliance.
Live Demo: Passport 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
Spain Passport OCR with the Python SDK
The official Python SDK handles file encoding, API communication, and structured passport results. Use the SDK directly or open the FastAPI tab for a server endpoint. Keep your API key in STRUCTOCR_API_KEY.
Prerequisite: `pip install structocr`; set the server-side `STRUCTOCR_API_KEY` environment variable.
Prefer another stack? Open the Node.js SDK + Express integration.
import os
from structocr import StructOCR
# Initialize API Client for Edge Processing
client = StructOCR(os.environ["STRUCTOCR_API_KEY"])
def extract_spain_passport():
# Supports local files (PDF/Images), Base64 encoded strings, or URLs
document_source = "spain_passport_sample.pdf"
try:
print(f"Executing passport data extraction API for {document_source}...")
result = client.scan_passport(document_source)
if result.get('success'):
data = result['data']
print("✅ Passport Extraction Successful!")
print(f"Passport #: {data.get('passport_number')}")
print(f"Name: {data.get('given_names')} {data.get('surname')}")
print(f"Nationality: {data.get('nationality')}")
print(f"DOB: {data.get('date_of_birth')}")
else:
print(f"❌ API Extraction Failed: {result.get('error')}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
extract_spain_passport()Technical Specs
- •Infrastructure: Distributed Global Edge Network
- •Latency: < 1s (Average response time)
- •Security: In-memory processing, zero data retention
- •Inputs Supported: PDF, File Upload (JPG/PNG/WebP), Base64 String, Image URL
- •Output: Structured JSON
Key Features
- •Official Python SDK: Handles image input, authentication, API communication, and structured results.
- •Multi-Format Processing: Natively parse multi-page PDFs or standard image formats.
- •Visual Extraction (VIZ): Reliably extracts data directly from the visual inspection zone alongside MRZ.
- •Flexible Payloads: Pass Base64 data directly from frontend clients to bypass intermediate storage.
JSON API Response Example
The Python SDK returns a dictionary matching this normalized JSON structure.
{
"success": true,
"data": {
"type": "passport",
"country_code": "ESP",
"nationality": "ESP",
"passport_number": "PA123456",
"surname": "GARCÍA",
"given_names": "ANTONIO",
"sex": "M",
"date_of_birth": "1975-01-20",
"place_of_birth": "MADRID",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2025-01-19",
"issuing_authority": "DGP"
}
}Frequently Asked Questions
Do I have to use the Python SDK?
No, our core product is a language-agnostic REST API. The Python library is simply a convenient wrapper. You can make direct HTTP POST requests using cURL, Node.js, Go, or any other language.
Does it work with older passport formats?
Yes, our passport extraction api is trained on diverse datasets to handle both legacy formats and modern biometric passport layouts globally.
How much does the passport data extraction API cost?
Our service operates on a transparent, pay-as-you-go model starting with free credits for testing. You can view our full pricing details to find a volume tier that fits your application's needs.
You May Also Like
Related tutorials, platform guides, and comparisons
Kazakhstan Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Kazakhstan passports with a server-side integration.
Tanzania Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Tanzania 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.
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.
Algeria Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Algeria passports with a server-side integration.
UK Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from UK passports with a server-side integration.
Belgium Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Belgium passports with a server-side integration.
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.
Tajikistan Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Tajikistan passports.
Switzerland Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Switzerland passports.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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.
Extracting ECR Status & File Numbers: Generic OCR vs. StructOCR Indian Passport API
Learn why generic text extractors fail to capture critical Indian KYC fields like ECR status and File Numbers, and how a specialized API structures this data automatically.
Heavy KYC SDKs vs. StructOCR Passport API for Mobile Apps
Discover why modern app developers are abandoning bulky on-device OCR SDKs in favor of lightweight, edge-deployed Passport APIs.
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 Passport OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Replit application. Build travel, hospitality, and global KYC flows using Replit Agent and Secrets.
Tesseract & PassportEye vs. StructOCR Passport API
A technical evaluation for developers deciding between open-source MRZ scanners and a dedicated cloud-based Passport OCR 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.