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).
| Input | Output |
|---|---|
| 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
| Header | Mandatory / Optional | Description | Input Format |
|---|---|---|---|
| content-type | Mandatory | This parameter defines the media type for the request payload | multipart/form-data |
| appId | Mandatory | The application identifier shared by HyperVerge. You can find the details in the dashboard's credentials tab | This should be a unique value |
| appKey | Mandatory | The application key shared by HyperVerge. You can find the details in the dashboard's credentials tab | This should be a unique value |
| transactionId | Mandatory | A unique identifier for tracking a user journey | This should be both unique and easily associated with the user's journey in your application(s) |
| uuid | Optional | This 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:
Each of the following parameters are alternate options that you can use in the request. Kindly use any one of them in the request.
| Parameter | Mandatory / Optional | Type | Description | Input Format | Default Value |
|---|---|---|---|---|---|
image | Mandatory | string | The 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 TIFF | Not Applicable |
pdf | Mandatory | string | The PDF file on which the Driving Licence OCR API will perform the OCR extraction. | Not Applicable | |
url | Mandatory | string | The public URL of the file on which the Driving Licence OCR API will perform the OCR extraction | Public URL | Not Applicable |
checkFace | Optional | string | Check if face is present on the DL. | yes / no | yes |
- 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.
- Send Image File
- Send PDF
- Send Public URL
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>"'
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 'pdf=@"<Enter_file_path_with_.pdf_extension>"'
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 'url="<Enter_the_public_URL>"'
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:
| Parameter | Type | Description |
|---|---|---|
status | string | The status of the request |
statusCode | string | The HTTP status code for the response |
result | array | An array containing the extracted details from the driving license |
result[].type | string | The type of document detected (e.g., "dl_face", "dl_noface") |
result[].details | object | Contains the extracted fields with their values and confidence scores |
result[].details.*.value | string | The extracted value for a specific field |
result[].details.*.conf | number | The confidence score with which the value is extracted (optional) |
Supported Document Types
The following table lists the supported document types and their extracted fields:
| Type | Fields 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.
- dl_face Type
- dl_noface Type
"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>
"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:
- Failed to Detect DL in Image
- Missing Document Input
- Multiple Documents Input
- Invalid File Size - 1
- Invalid File Size - 2
{
"status": "failure",
"statusCode": "422",
"error": "No Driving License detected"
}
{
"status": "failure",
"statusCode": "400",
"error": "API call requires one input image"
}
{
"status": "failure",
"statusCode": "400",
"error": "API call handles only one input image"
}
{
"status": "failure",
"statusCode": "400",
"error": "image size cannot be greater than 6MB"
}
{
"status": "failure",
"statusCode": "413",
"error": "File too large"
}
- Invalid PDF
- Download Failed
- Time Out
- Size Issue
{
"status": "failure",
"statusCode": "400",
"error": "Invalid PDF"
}
This following error response is returned only when the request contains the URL input is provided. It is returned when,
- URL contains an invalid domain.
- Invalid url is provided.
- Remote end is unreachable.
- Remote end resets connection.
{
"status": "failure",
"statusCode": "424",
"error": "Download from URL Failed"
}
This error response is returned only when the request contains a URL input. The timeout is set to 5 seconds.
{
"status": "failure",
"statusCode": "424",
"error": "Download from URL timed out"
}
{
"status": "failure",
"statusCode": "424",
"error": "Url contains an image of size larger than 12582912 bytes"
}
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 Code | Error Message | Error Description | Error Resolution |
|---|---|---|---|
| 400 | API call requires one input image | The 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 |
| 400 | API call handles only one input image | Multiple document inputs were provided in the request | Provide only one input (image, pdf, or url) in the request |
| 400 | image size cannot be greater than 6MB | The uploaded image exceeds the supported size limit of 6MB | Ensure the image file size is 6MB or less |
| 400 | Invalid PDF | The provided PDF file is invalid or corrupted | Ensure the PDF file is valid and not corrupted |
| 401 | Missing/Invalid credentials | The request is either missing the mandatory appId and appKey combination or has invalid values | Provide valid appId and appKey credentials in the request |
| 413 | File too large | The uploaded file exceeds the maximum allowed size | Reduce the file size and try again |
| 422 | No Driving License detected | No valid driving license document could be detected in the provided image | Ensure the image contains a clear, readable driving license document |
| 424 | Download from URL Failed | The URL contains an invalid domain, invalid URL is provided, remote end is unreachable, or remote end resets connection | Verify the URL is valid and accessible, and try again |
| 424 | Download from URL timed out | The download from the provided URL exceeded the 5-second timeout | Ensure the URL is accessible and try again |
| 424 | Url contains an image of size larger than 12582912 bytes | The image at the provided URL exceeds the maximum allowed size | Use a URL pointing to an image that is 12582912 bytes or smaller |
| 425 | Network tampering detected | Network tampering was detected in the request | Check your network connection and try again |
| 429 | Requests rate limit exceeded | The rate limit for API requests has been exceeded | Wait before making additional requests or contact HyperVerge for rate limit adjustments |
| 500 | Internal Server Error | There was an error with HyperVerge's server | Please check the request headers or contact the HyperVerge team for resolution |