Skip to main content

Driving Licence OCR API

The following document highlights the details of the Driving Licence OCR API.

API Description

Objective

The Driving Licence OCR API scans and extracts information from an image of an Indian driving licence document using optical character recognition(OCR).

InputOutput
An image or PDF file containing a user's Indian driving license. The data extracted from the document.

API URL

https://ind-docs.hyperverge.co/v2.0/readDL

API Endpoint

readDL

Overview

The Driving Licence OCR API is RESTful and uses standard HTTP verbs and status codes. The responses are in JSON format and you should upload all images and files as form-data through a POST request.

Method - POST

Authentication

You need a unique pair of application ID ( appId ) and application key ( appKey ) from HyperVerge to verify your identity for accessing the API.

Headers

HeaderMandatory / OptionalDescriptionInput Format
content-type MandatoryThis parameter defines the media type for the request payloadmultipart/form-data
appId MandatoryThe application identifier shared by HyperVerge. You can find the details in the dashboard's credentials tabThis should be a unique value
appKey MandatoryThe application key shared by HyperVerge. You can find the details in the dashboard's credentials tabThis should be a unique value
transactionIdMandatoryA unique identifier for tracking a user journeyThis should be both unique and easily associated with the user's journey in your application(s)
uuidOptionalThis is an advanced feature designed to prevent tampering of response by a man in the middle. If uuid is set, the response will include an X-Response-Signature header which will have a checksum of the response body signed with the uuid and a private key.This should be a unique value

Inputs

The following table provides the details of the parameters required for the Driving Licence OCR API's request body:

Info

Each of the following parameters are alternate options that you can use in the request. Kindly use any one of them in the request.

ParameterMandatory / OptionalTypeDescriptionInput FormatDefault Value
imageMandatorystringThe image file on which the Driving Licence OCR API will perform the OCR extraction. The API supports JPEG, PNG and TIFF images.JPEG, PNG, or TIFFNot Applicable
pdfMandatorystringThe PDF file on which the Driving Licence OCR API will perform the OCR extraction.PDFNot Applicable
urlMandatorystringThe public URL of the file on which the Driving Licence OCR API will perform the OCR extractionPublic URLNot Applicable
checkFaceOptionalstringCheck if face is present on the DL.yes / noyes
Input Image Constraints
  • For the deep learning servers to extract text out of an image, the rule of thumb that needs to be followed is that the text in the image should be legible.
  • Higher size of image will lead to higher upload and processing time. Hence the size of image should be reduced as much as possible while ensuring that above condition is met.
  • A general guideline that can be followed is to keep the width of the ID card image at least 800 pixels and to keep JPEG compression quality factor above 80%.
  • The aspect ratio of the input image should be same as the aspect ratio of the original document. Kindly take care of the aspect ratio when resizing the image.
  • If integrating into an Android or iOS app, please use the HyperSnap SDK for Android and iOS. This SDK provides camera functionality for capturing images of ID cards while taking care of all the above requirements.

Request

The following code snippet demonstrates a standard curl request for the Driving Licence OCR API. You can send an image file, a PDF file or the public URL of the document in the request.

curl --location --request POST 'https://ind-docs.hyperverge.co/v2.0/readDL' \
--header 'Content-Type: multipart/form-data' \
--header 'appId: <Enter_the_HyperVerge_appId>' \
--header 'appKey: <Enter_the_HyperVerge_appKey>' \
--header 'transactionId: <Enter_the_HyperVerge_transactionID>' \
--form 'image=@"<Enter_image_path_with_extension>"'

Success Response

The following code snippet demonstrates a success response from the Driving Licence OCR API:

{
"status" : "success",
"statusCode" : "200",
"result" : [{
"type" : "kyc_type",
"details" : {
"field-1" : {
"value": "<value extracted>",
"conf": "(optional):<the confidence score with which the value is extracted>"
},
"field-2" : {
"value": "<value extracted>",
"conf": "(optional):<the confidence score with which the value is extracted>"
},
"field-3" : {
"value": "<value extracted>",
"conf": "(optional):<the confidence score with which the value is extracted>"
},
..
},
}]
}

Success Response Details

The following table outlines the details of the success response from the Driving Licence OCR API:

ParameterTypeDescription
statusstringThe status of the request
statusCodestringThe HTTP status code for the response
resultarrayAn array containing the extracted details from the driving license
result[].typestringThe type of document detected (e.g., "dl_face", "dl_noface")
result[].detailsobjectContains the extracted fields with their values and confidence scores
result[].details.*.valuestringThe extracted value for a specific field
result[].details.*.confnumberThe confidence score with which the value is extracted (optional)

Supported Document Types

The following table lists the supported document types and their extracted fields:

TypeFields Extracted
Driving Licence with Face (dl_face)name, doi, pin, dob, swd, doe, address, dl_num
Driving Licence with No Face (dl_noface)

Each of the details object in the JSON response for a supported document type will have the following schemas.

"dob": {
"value": <type: String, description: Date of birth of the holder>,
"conf": <type: Number, description: Confidence For extracted Date of Birth>
},
"swd": {
"value": <type: String, description: Fathers/Husbands name of the holder>,
"conf": <type: Number, description: Confidence For extracted value>
},
"name": {
"value": <type: String, description: Name of the Holder>,
"conf": <type: Number, description: Confidence For extracted Name>
},
"dl_num": {
"value": <type: String, description: DL Number of the Holder>,
"conf": <type: Number, description: Confidence For extracted DL Number>
},
"doi": {
"value": <type:String description: Date of Issue of DL card>,
"conf": <type: Number, description: Confidence For extracted Date of Issue>
},
"doe": {
"value": <type:String description: Date of Expiry of DL card>,
"conf": <type: Number, description: Confidence For extracted Date of Expiry>
},
"pin": {
"value": <type:String description: PIN Code>,
"conf": <type: Number, description: Confidence>
},
"address": {
"value": <type:String description: Address>,
"conf": <type: Number, description: Confidence>
},
"tag": <type: String, description: Unique identifier For extracted document sub-type>

Error Responses

The following are some error responses from the Driving Licence OCR API:

{
"status": "failure",
"statusCode": "422",
"error": "No Driving License detected"
}
{
"status": "failure",
"statusCode": "400",
"error": "Invalid PDF"
}

Error Response Details

A failure or error response contains a failure status with a relevant status code and error message.
The following table lists all error responses:

Status CodeError MessageError DescriptionError Resolution
400API call requires one input imageThe request did not contain the mandatory document input (image, pdf, or url)Provide a valid image file, PDF file, or public URL in the request
400API call handles only one input imageMultiple document inputs were provided in the requestProvide only one input (image, pdf, or url) in the request
400image size cannot be greater than 6MBThe uploaded image exceeds the supported size limit of 6MBEnsure the image file size is 6MB or less
400Invalid PDFThe provided PDF file is invalid or corruptedEnsure the PDF file is valid and not corrupted
401Missing/Invalid credentialsThe request is either missing the mandatory appId and appKey combination or has invalid valuesProvide valid appId and appKey credentials in the request
413File too largeThe uploaded file exceeds the maximum allowed sizeReduce the file size and try again
422No Driving License detectedNo valid driving license document could be detected in the provided imageEnsure the image contains a clear, readable driving license document
424Download from URL FailedThe URL contains an invalid domain, invalid URL is provided, remote end is unreachable, or remote end resets connectionVerify the URL is valid and accessible, and try again
424Download from URL timed outThe download from the provided URL exceeded the 5-second timeoutEnsure the URL is accessible and try again
424Url contains an image of size larger than 12582912 bytesThe image at the provided URL exceeds the maximum allowed sizeUse a URL pointing to an image that is 12582912 bytes or smaller
425Network tampering detectedNetwork tampering was detected in the requestCheck your network connection and try again
429Requests rate limit exceededThe rate limit for API requests has been exceededWait before making additional requests or contact HyperVerge for rate limit adjustments
500Internal Server ErrorThere was an error with HyperVerge's serverPlease check the request headers or contact the HyperVerge team for resolution
Was this helpful?
Ask AIBeta
Hi! How can I help?
Ask me anything about HyperVerge products, APIs, and SDKs.
Try asking: