βοΈPassport
This API provides Data Extraction for Travel Passport documents, particularly the
identity page containing the individual's information.The "validity" metric in this API's successful response indicates the validity of the data extracted from the document.
Passport OCR
POST https://valifystage.com/api/v1.1/ocr/
Headers
Name
Type
Description
Content-Type
string
application/json
Authentication
string
Bearer <access-token>
Request Body
Name
Type
Description
document_type
string
passport
data
object
Object containing the parameters below:
{
img: <base64 str>,
bundle_key: <str>,
lang: <str>
}
Status Codes
{
"result": {
"expiration_date": '<string>',
"date_of_birth": '<string>',
"name": '<string>',
"nationality":'<string>',
"surname": '<string>',
"passport_number": '<string>',
"sex": '<string>',
"type": '<string>',
"validity": '<int>'
},
"transaction_id": '<string>',
"trials_remaining": '<int>'
}{
"message": "Bad Request β invalid request received (e.g. missing Bundle key, required parameters or invalid json) | Make sure all the required parameters are included"
}{
"message": "Unauthorized β your Bundle key is invalid"
}{
"message": "Forbidden β specified access_token could not be found"
}{
"message": "Not Found"
}{
"message": "Unsupported Media Type"
}{
"message": "<error-description>",
"error_code": <valify-error-code>
}{
"message": "Internal Server Error"
}Integration
Download the JSON file from here.
Open Postman and click on Import.

Drop the JSON file.

Click on "Passport" and then click on "Authorization" and replace the <access token> field with your access token and then click on "Body".

Click on "Body" then fill in the required data and hit "Send".

import requests
import base64
def base64_encode(file_name):
with open(file_name, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode()
return encoded_string
return ""
image = base64_encode('<image path>')
token = "<token>" # Place your token here
data = {
'document_type': 'passport',
'data':
{
'img': image,
'bundle_key': '<bundle key>', # Place your bundle key here
'lang': '<str>' # optional
}
}
r = requests.post("https://valifystage.com/api/v1.1/ocr/",
json=data,
headers={'Authorization': 'Bearer %s' % token}
)
print(r.json())Last updated