βοΈMoroccan Passport
This API provides Data Extraction for Moroccan Travel Passport documents.
Moroccan Passport OCR
POST
https://valifystage.com/api/v1/ocr/
Headers
Name
Type
Description
Content-Type
string
application/json
Authentication
string
bearer <access-token>
Request Body
Name
Type
Description
Notes
document_type
string
mar_passport
data
object
Object containing the parameters below:
{
img: <base64 str>,
bundle_key: <str>,
lang: <str>
}
Please note thatimg
cannot be empty (i.e., missing or an empty string ""
).
Status Codes
{
"result": {
"first_name": {
"arabic": <string>,
"latin": <string>
},
"family_name": {
"arabic": <string>,
"latin": <string>
},
"nationality": {
"arabic": <string>,
"latin": <string>
},
"sex": <string>,
"place_of_birth": <string>,
"date_of_issue": <string>,
"date_of_expiry": <string>,
"authority": <string>,
"residence": <string>,
"date_of_birth": <string>,
"type": <string>,
"code": <string>,
"passport_no": <string>,
"id_card_no": <string>
},
"transaction_id": <string>,
"trials_remaining": <int>
}
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 ""
front_image = base64_encode('<image path>') # Place your front image here
back_image = base64_encode('<image path>') # Place your back image here
token = "<token>" # Place your token here
data = {
'document_type': 'mar_passport',
'data':
{
'img': <'passport_base_64_img'>
'bundle_key': '<bundle key>', # Place your bundle key here
'lang': '<str>' # optional, default: en
}
}
r = requests.post("https://<base-url>/api/v1/ocr/",
json=data,
headers={'Authorization': 'Bearer %s' % token}
)
print(r.json())
Last updated