Welcome to the Valify API integration guide. This section provides a step-by-step guide to integrating Valify services into your application using our API.
1) Prerequisites
Authentication token: This can be generated through our auth API.
Bundle Key: This will be found in the email you received upon signup.
2) Setting up
2.1) Generate a token
for more details about OAuth Token go to:OAuth Token
r = requests.post("https://www.valifystage.com/api/o/token/",
data={
'username': '<username>',
'password': '<password>',
'client_id': '<client id>',
'client_secret': '<client secret>',
'grant_type': 'password' #default value no need to change
}
)
token=r.json()['access_token']
NID OCR
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,
'verify_document':'false',
'bundle_key': '<bundle key>', # Put your bundle key here
'lang': '<lang>'
}
}
r = requests.post("https://valifystage.com/api/v1.4/ocr/",
json=data,
headers={'Authorization': 'Bearer %s' % token}
)
result = r.json()
print(result)