Photo ID OCR API
Reads a photo of an Indian ID and returns the document type, number, name, date of birth, father's name and address where printed, with confidence and quality flags.
- Source
- Our OCR models trained on Indian identity documents
- Turnaround
- Real time, one to three seconds
- Endpoint
- POST /v1/ocr/id
- Who can use it
- Any business with the user's consent to process their ID image.
Overview
Typing details from an ID photo is slow and error-prone, and so is asking users to do it. Send a photo of an Indian ID and we return the document type, number, name, date of birth, father's name and address where printed. A confidence score and quality flags tell you when to ask for a better photo. Aadhaar numbers can be masked in the same call.
Good to know
OCR reads the card, it doesn't validate it. A well-made fake card will read cleanly, so always verify the number against the source.
What you get
- Auto-detects the documentNo need to ask the user which ID they uploaded. We detect it and pick the right fields.
- Aadhaar masking includedGet the Aadhaar number masked to the last four digits and a masked image to store.
- Quality and photocopy flagsBlur, glare, cropping and photocopies are flagged so you don't accept a bad scan.
- Front and backSend both sides where the address is on the back, as with Aadhaar and some DLs.
Request
POST https://api.ampletrails.com/v1/ocr/id
| Field | Type | Status | Description |
|---|---|---|---|
image_front | string | Required | Front of the document as base64 or HTTPS URL |
image_back | string | Optional | Back of the document, if it carries the address |
doc_type | string | Optional | Expected type (aadhaar, pan, voter_id, dl, passport); auto-detected if omitted |
mask_aadhaar | boolean | Optional | Return a masked Aadhaar image and number |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
doc_type | Detected document type | pan |
id_number | Document number | ABCDE1234F |
name | Name as printed | RAVI KUMAR |
father_name | Father's name, where printed | SURESH KUMAR |
dob | Date of birth | 1990-05-14 |
address | Address, where printed | null |
confidence | Overall extraction confidence from 0 to 100 | 97 |
quality_flags | Issues like blur, glare, cropping or a photocopy | [] |
Example
curl -X POST https://api.ampletrails.com/v1/ocr/id \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_front": "data:image/jpeg;base64,…", "image_back": "data:image/jpeg;base64,…", "doc_type": "pan", "mask_aadhaar": true, "consent": "Y"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/ocr/id",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"image_front": "data:image/jpeg;base64,…",
"image_back": "data:image/jpeg;base64,…",
"doc_type": "pan",
"mask_aadhaar": True,
"consent": "Y"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/ocr/id", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image_front": "data:image/jpeg;base64,…",
"image_back": "data:image/jpeg;base64,…",
"doc_type": "pan",
"mask_aadhaar": true,
"consent": "Y"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/ocr/id");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("AMPLE_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["image_front" => "data:image/jpeg;base64,…", "image_back" => "data:image/jpeg;base64,…", "doc_type" => "pan", "mask_aadhaar" => true, "consent" => "Y"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"doc_type": "pan",
"id_number": "ABCDE1234F",
"name": "RAVI KUMAR",
"father_name": "SURESH KUMAR",
"dob": "1990-05-14",
"address": null,
"confidence": 97,
"quality_flags": "[]"
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
Faster onboarding forms
Prefill name, date of birth and ID number from a photo, then let the user correct anything.
Back-office digitisation
Convert stacks of scanned KYC files into structured records.
Agent-assisted KYC
Field agents photograph the ID and the form fills itself.
Questions about this API
Does OCR verify the document?
No. It reads what is printed. Run the extracted number through PAN, DL or Voter ID verification to check it against government records.
Which documents are supported?
Aadhaar, PAN, Voter ID, driving licence and passport. For other countries, see Global ID verification.
What about regional-language text?
We return the English fields. Names printed only in a regional script are transliterated where possible, so check those with the user.
Can it read a photo of a screen?
It will usually read it, but we flag it. Many teams reject screen photos because they're a common sign of a borrowed document.
Try the Photo ID OCR API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.