US Driver License OCR with Python SDK
Send a state-issued driver license to the official Python SDK and receive normalized identity, validity and licence fields.

Reading United States Driver Licenses
State name, licence number, class, restrictions and address placement vary across issuing jurisdictions. Manual transcription adds delays and creates avoidable formatting errors when a team needs to move licence data into onboarding, rental or mobility systems.
A Server-Side Python SDK Workflow
The StructOCR driver license endpoint accepts a Base64-encoded image or PDF and returns normalized fields that are visible on the document. Typical results include the document number, holder name, dates, issuing region, address and vehicle class; optional fields may be null when they are absent or unreadable.
Common Integration Scenarios
- Vehicle rental: Pre-fill customer and licence details before a vehicle handover.
- Driver onboarding: Move visible licence fields into a review queue without retyping the card.
- Fleet operations: Capture licence classes and validity dates for internal driver records.
Live Demo: Driver License OCR 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
US Driver License OCR with Python SDK
The official Python SDK reads a supported local file and calls /v1/driver-license. Open the FastAPI tab for a server route using the same SDK method.
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
client = StructOCR(os.environ["STRUCTOCR_API_KEY"])
result = client.scan_driver_license("driver-license.jpg")
if result.get("success"):
data = result["data"]
print(data.get("document_number"))
print(data.get("given_names"), data.get("surname"))
else:
print(result.get("error"))Technical Specs
- •Endpoint: POST /v1/driver-license
- •Input: Base64-encoded JPG, PNG, WebP, or PDF in JSON (Max 4.5MB)
- •Authentication: Server-side x-api-key header handled by the SDK
- •Cost: 2 credits per scan
- •Output: Structured JSON
Key Features
- •Regional output: Returns country and issuing region when visible.
- •Licence fields: Extracts document number, validity dates and vehicle class when present.
- •Identity fields: Returns the printed holder name, birth details and address when readable.
- •Optional details: Preserves supported country-specific fields under extra_details.
JSON Response Example
Fields are returned when present and legible on the submitted licence; country-specific details may appear in extra_details.
{
"success": true,
"data": {
"type": "drivers_license",
"country_code": "USA",
"region": "California",
"document_number": "D1234567",
"personal_number": null,
"surname": "DOE",
"given_names": "JANE",
"sex": "F",
"date_of_birth": "1990-04-18",
"place_of_birth": null,
"date_of_issue": "2024-06-14",
"date_of_expiry": "2029-04-18",
"date_of_first_issue": null,
"issuing_authority": "CALIFORNIA DMV",
"address": "123 MARKET ST, SAN FRANCISCO, CA 94105",
"vehicle_class": "C",
"extra_details": {
"card_security_number": "01234567890"
}
}
}Frequently Asked Questions
Which fields can the US driver license API return?
The response can include country_code, region, document_number, personal_number, surname, given_names, sex, birth details, issue and expiry dates, issuing_authority, address, vehicle_class and extra_details. Fields not present or not legible can be null.
Can I use the other SDK language?
Yes. This tutorial has a paired Node.js and Express version linked in the integration section.
You May Also Like
Related tutorials, platform guides, and comparisons
US Driver License OCR with Node.js SDK
Extract structured fields from a United States state-issued driver license with the StructOCR Node.js SDK and TypeScript + Express.
Philippines Driver License OCR with Python SDK
Extract structured fields from a Philippines LTO driver's license with the StructOCR Python SDK and FastAPI.
Python Driver License OCR SDK & API
Stop struggling with manual data entry. Integrate our driver license OCR SDK (Python wrapper) to extract structured JSON in <3s. Upload an image for a free test! Secure, accurate, and developer-friendly.
Canada Driver License OCR with Python SDK
Extract structured fields from a Canada provincial driver licence with the StructOCR Python SDK and FastAPI.
Brazil Driver License OCR with Python SDK
Extract structured fields from a Brazil Carteira Nacional de Habilitação (CNH) with the StructOCR Python SDK and FastAPI.
Australia Driver License OCR with Python SDK
Extract structured fields from a Australia state or territory driver licence with the StructOCR Python SDK and FastAPI.
UK Driver License OCR with Python SDK
Extract structured fields from a United Kingdom photocard driving licence with the StructOCR Python SDK and FastAPI.
US Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from US passports with a server-side integration.
Canada Driver License OCR with Node.js SDK
Extract structured fields from a Canada provincial driver licence with the StructOCR Node.js SDK and TypeScript + Express.
Brazil Driver License OCR with Node.js SDK
Extract structured fields from a Brazil Carteira Nacional de Habilitação (CNH) with the StructOCR Node.js SDK and TypeScript + Express.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Driver's License OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Bolt.new app. Build car rental and mobility onboarding flows right in your browser.
Add Driver's License OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API using the Cursor AI code editor. Build car rental and mobility onboarding flows rapidly.
Add Driver's License OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Lovable.dev app. Build car rental and mobility onboarding flows with zero backend.
Add Driver's License OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Replit application. Build car rental and mobility onboarding flows using Replit Agent and Secrets.
Add Driver's License OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a v0 by Vercel app. Build car rental and mobility onboarding 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.
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.