Documentation
  • Introduction
  • ⚡Quick Guide
  • APIs
    • 🇦🇪UAE Resident ID OCR
    • 🔑OAuth Token
    • 🆔National ID OCR
      • 🔁API Response
    • 🧑‍💼Face Match
      • Face Match (Two Images)
      • Face Match (Image & Transaction ID)
    • ✈️Passport
    • ✈️Libyan passport
    • 🚗Car License
    • ↔️Transliteration
      • National ID Transliteration
      • Commercial Register Translation
      • Names Transliteration
    • 🏫Know Your Business (eKYB)
      • 📖Data Extraction & Verifications
        • Egyptian Commercial Register ID OCR
          • ✅With Verification
        • Egyptian Tax Card OCR
    • 📄Valify Sanction Shield
      • Sanction Shield v2.1.0
    • Sanction Shield v2.0.0
    • 🛡️Supported lists
    • ❓Transaction Inquiry
    • 📷Fetch Images
    • 🔒OTP
      • 📲Send Phone OTP
      • ✅Verify Phone OTP
      • 📥Send Email OTP
      • ✅Verfiy Email OTP
    • Response Data Validation
  • Error Codes
    • Valify Error Codes
    • HTTP Codes
  • References
Powered by GitBook
On this page
  • Egyptian National ID OCR
  • Integration
  1. APIs

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 Body

Name
Type
Description

document_type*

string

egy_nid

data*

object

Request details

{
    "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>',
    },
    
    "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"
}

Note: The object below is one of the parameters included in the request as mentioned in the previous section

data <object>
"bundle_key": "<bundle_key>",
"extras":[
            "advanced_confidence",
            "document_verification_plus",
            "profession_analysis"
    ],
"front_img": "<base64-encoded-image",
"back_img": "<base64-encoded-image",
"lang": "<string>"

Integration

  1. Download the JSON file from here.

  1. Open Postman and click on Import.

  1. Drop the JSON file.

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

  1. 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)
PreviousOAuth TokenNextAPI Response

Last updated 4 months ago

Please note that the front and back images should be converted to base 64 format. This can be done via an online tool;

🆔
https://base64.guru/converter/encode/image/jpg
1KB
Valify OCR v1.5 Demo.postman_collection.json