New York Driver License OCR: Extract Fields with Python

Extract visible fields from New York driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

City rental and car-share intake: what needs review

Separate licence number, birth date and expiry before record matching. Never treat a readable identification card as proof of driving entitlement without document review. In a production intake, keep the uploaded document associated with the correct application record before extraction. A legible name alone does not establish that the number, dates and address were captured correctly. Avoid filling missing values from a previous booking or a customer profile without recording that separate source.

Map New York document evidence into your backend

Check the document type, printed issuing region and date labels before using the result. Keep licence class and any visible restrictions available for review. OCR reads evidence from a card; it does not check a live driving record or determine vehicle eligibility. Send the image to the driver license API and keep extracted evidence separate from your approval decision. The same endpoint handles the submitted image; the article's country or state context does not force the API to return that jurisdiction. Compare the returned country and region with the source before saving the result. Building a US onboarding flow? The US driver license scanner API covers every state and returns the Document Discriminator (DD), or try a photo in the free online driver license scanner.

A reviewable intake workflow

  • City rental and car-share intake: Separate licence number, birth date and expiry before record matching. Never treat a readable identification card as proof of driving entitlement without document review.
  • Map fields without losing their meaning: Store document_number as text, keep surname and given_names in their own fields, and retain source images according to your document-handling policy. Date parsing failures should be reviewable instead of becoming today's date.
  • Compare a resubmitted document: Keep a prior extraction and a new extraction as separate events. A change in number, name or expiry should produce a review item, not an automatic overwrite of a trusted record.
  • Export only the fields your workflow uses: Map the response to your form explicitly. Keep the licence class separate from vehicle registration, insurance and employer approval.
Need more testing? Create a free account to get 200 free credits (equals 100 Driver License scans).

Python request for New York driver license OCR

This REST example sends a local image as Base64 JSON. Run it on a backend and keep the API key in an environment variable. The printed example below is deliberately synthetic and is not a valid document-number format specimen.

Prerequisite: Python 3, pip install requests; STRUCTOCR_API_KEY set on the server

import base64
import os
import requests

with open("new-york-driver-license.jpg", "rb") as source:
    encoded = base64.b64encode(source.read()).decode("ascii")

response = requests.post(
    "https://api.structocr.com/v1/driver-license",
    headers={"x-api-key": os.environ["STRUCTOCR_API_KEY"]},
    json={"img": encoded},
    timeout=60,
)
response.raise_for_status()
result = response.json()
if not result.get("success"):
    raise RuntimeError("Extraction was not successful; inspect the response securely")
data = result.get("data") or {}
required = ["document_number", "surname", "date_of_expiry"]
missing = [field for field in required if not data.get(field)]
# Queue incomplete records; do not log identity data in production.
print({"needs_review": bool(missing), "missing_fields": missing})

Technical Specs

  • •Endpoint: POST /v1/driver-license
  • •Authentication: Server-side x-api-key header
  • •Input: Base64 image in JSON img; use a readable JPG, PNG or WebP for this example
  • •File size: Up to 4.5MB decoded
  • •Standard processing: 2 credits per scan
  • •Output: JSON; retain incomplete results for review

Key Features

  • •Local extraction concern: Separate licence number, birth date and expiry before record matching. Never treat a readable identification card as proof of driving entitlement without document review.
  • •Identifiers: Keep strings intact; do not coerce document numbers into numeric spreadsheet columns.
  • •Dates: Validate date syntax and labels. An unexpected value needs source review, not silent correction.
  • •Image evidence: Preserve all card or page edges, reduce glare and avoid cropping small text.

Illustrative response fields

Synthetic subset of the response for mapping purposes. Values and dates are examples, not a real scan or an assertion about document validity periods. Actual fields depend on the submitted document.

{
  "success": true,
  "data": {
    "type": "drivers_license",
    "region": "NY",
    "country_code": "USA",
    "document_number": "EXAMPLE-NOT-A-REAL-ID",
    "surname": "EXAMPLE",
    "given_names": "PERSON",
    "date_of_birth": "1990-01-15",
    "date_of_issue": "2024-04-12",
    "date_of_expiry": "2029-04-12",
    "issuing_authority": null,
    "vehicle_class": null,
    "address": null,
    "extra_details": {}
  }
}

Frequently Asked Questions

What is the main concern with New York driver license intake?

Separate licence number, birth date and expiry before record matching. Never treat a readable identification card as proof of driving entitlement without document review.

Does extracting a number verify the document?

No. Extraction returns visible data. Authenticity checks, live registry checks and the final onboarding decision are separate processes.

What should happen when a date or name is unreadable?

Keep the record pending and request a clearer image or a manual review. Do not infer a date from an account profile or shorten a name to make it match.

Where should I check document-format references?

Use the USAGov state motor vehicle services directory to find the issuing jurisdiction. Check the specific card version before adding format rules; this tutorial does not prescribe a fixed number length for every version.

Can the same workflow run without Python?

Yes. Any backend that can send an authenticated JSON request can call /v1/driver-license. See the API reference for the current response contract.

You May Also Like

Related tutorials, platform guides, and comparisons

Country Tutorial

Alabama Driver License OCR: Extract Fields with Python

Extract visible fields from Alabama driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

California Driver License OCR: Extract Fields with Python

Extract visible fields from California driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

Virginia Driver License OCR: Extract Fields with Python

Extract visible fields from Virginia driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

North Dakota Driver License OCR: Extract Fields with Python

Extract visible fields from North Dakota driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

Connecticut Driver License OCR: Extract Fields with Python

Extract visible fields from Connecticut driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

North Carolina Driver License OCR: Extract Fields with Python

Extract visible fields from North Carolina driver license images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.

Python · Driver License
Country Tutorial

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.

Python · Driver License
Country Tutorial

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.

Python · Driver License
Country Tutorial

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.

Node.js · Driver License
Country Tutorial

Australia Driver License OCR with Node.js SDK

Extract structured fields from a Australia state or territory driver licence with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

Integration

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.

Driver License
Integration

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.

Driver License
Integration

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.

Driver License
Integration

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.

Driver License
Integration

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.

Driver License
Comparison

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.

Comparison

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.

Instant Access Cancel Anytime No Credit Card