ποΈMoroccan Residency Card
This API provides Data Extraction for Moroccan Residency Card documents.
Moroccan Residency Card 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_resident_id
data
object
Object containing the parameters below:
{
"front_img": <string>, // optional default is ""
"back_img": <string>, // optional default is ""
"bundle_key": <string>,
"lang": <string> // optional default is "en"
}
Please note that both front_img
and back_img
cannot be empty (i.e., missing or an empty string ""
).
Status Codes
{
"result": {
"first_name": {
"arabic": <string>,
"latin": <string>
},
"last_name": {
"arabic": <string>,
"latin": <string>
},
"birth_place": {
"arabic": <string>,
"latin": <string>
},
"father_name": {
"arabic": <string>,
"latin": <string>
},
"mother_name": {
"arabic": <string>,
"latin": <string>
},
"address": {
"arabic": <string>,
"latin": <string>
},
"birth_date": <string>,
"expiration_date": <string>,
"gender": <string>,
"civil_status_num": <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_resident_id',
'data':
{
'front_img': front_image,
'back_img': back_image,
'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