🇪🇬National ID OCR
This API provides Data Extraction for the Egyptian National ID.Egyptian National ID OCR
POST https://<base-url>/api/v1.5/ocr/
Headers
Name
Type
Description
Content-Type*
string
application/json
Authentication*
string
Bearer <access-token>
Request
Name
Type
Description
document_type*
string
egy_nid
data*
object
Request details
{
front_img: <base64 str>,
back_img: <base64 str>,
bundle_key: <str>,
lang: <str>
}
Status Codes
{
"result":
{
"first_name": '<string>',
"full_name": '<string>',
"street": '<string>',
"front_nid": '<string>',
"serial_number": '<string>',
"back_nid":'<string>',
"release_date": '<string>',
"gender": '<string>',
"marital_status": '<string>'
"profession": '<string>',
"religion":'<string>',
"husband_name": '<string>',
"date_of_birth": '<string>',
"age":'<int>',
"birth_governarate": '<string>',
"police_station": '<string'>,
"governorate": '<string>',
"expiry_date": '<string>',
},
"advanced_confidence":
{
"is_face_fraud_detected": '<boolean>'
},
"document_verification_plus":
{
"expired": '<boolean>',
"front_data_validity": '<boolean>',
"back_data_validity": '<boolean>',
"is_front_greyscale": '<boolean>',
"is_back_greyscale": '<boolean>'
},
"profession_analysis":
{
"workplace": '<string>',
"profession_categorization": '<string>',
},
"document_liveness":
{
"is_front_document_live": '<boolean>',
"front_document_format": '<string>',
"is_back_document_live": '<boolean>',
"back_document_format": '<string>'
},
"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"
}{
"message": "Internal Server Error"
}Integration
Download the JSON file from here.
Open Postman and click on Import.

Drop the JSON file.

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

After clicking on "Body", fill in the required fields then click Send.

import requests
import base64
import json
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>')#Put your front image path here
back_image = base64_encode('<image path>')#Put your back image path here
token = "<token>"
r = requests.post("https://www.valifystage.com/api/o/token/",
data={
'username': '<username>', #Put all your credentials in those fields
'password': '<password',
'client_id': '<client_id>',
'client_secret': '<client_secret>',
'grant_type': 'password'
}
)
token=r.json()['access_token']
data = {
'document_type': 'egy_nid',
'data':
{
'front_img': front_image,
'back_img': back_image,
'bundle_key': '<bundle key>', # Put your bundle key here
'extras': ["document_verification_plus", "advanced_confidence"]
'lang': '<lang>'
}
}
r = requests.post("https://valifystage.com/api/v1.5/ocr/",
json=data,
headers={'Authorization': 'Bearer %s' % token}
)
result = r.json()
print(result)Last updated