> For the complete documentation index, see [llms.txt](https://valify.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://valify.gitbook.io/documentation/introduction/quick-guide.md).

# Quick Guide

***

## 1) Prerequisites

* **Authentication token:** This can be generated through our auth API.&#x20;
* **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](/documentation/apis/oauth-token.md)

{% tabs %}
{% tab title="Postman" %}

1. Download the JSON file from here.&#x20;

{% file src="/files/8qnGy0YLOcmHEV6t0jIH" %}

2. Open Postman and click on Import.

<figure><img src="/files/wZPToT6VKScrevX4e9YR" alt=""><figcaption></figcaption></figure>

3. Drop the JSON file.&#x20;

<figure><img src="/files/vxwVXjcimzxFOvUETnv8" alt=""><figcaption></figcaption></figure>

4. Choose "Access Token" as shown below and update the "Body" with your credentials then click "Send".&#x20;

   <figure><img src="/files/sVIVhAOeVYZx3ceS8Z54" alt=""><figcaption></figcaption></figure>
5. The access token will be shown in the response.&#x20;

<figure><img src="/files/y1BYbwnapfIXlRgBWmQV" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Please note that the token can be used within 10 minutes and needs to be generated again.&#x20;
{% endhint %}
{% endtab %}

{% tab title="Python" %}
Copy this code and put your credentials to easily generate the access token.

```python
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']
```

{% endtab %}
{% endtabs %}

## *3) Hit your first API request!*

{% tabs %}
{% tab title="Postman" %}

1. Download the JSON file from here.

{% file src="/files/iqEWKrhuDI9OpVpHxSPX" %}

2. Open Postman and click on Import.

<figure><img src="/files/wZPToT6VKScrevX4e9YR" alt=""><figcaption></figcaption></figure>

3. Drop the JSON file.

<figure><img src="/files/2OPVt7kf6vMXnwo89oSX" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/quYCzTmHAiMulKXm7zmx" alt=""><figcaption></figcaption></figure>

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

{% hint style="info" %}
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>&#x20;
{% endhint %}

<figure><img src="/files/iDFB6NJMZfJb7190kXTx" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Python" %}
{% code title="NID OCR " overflow="wrap" fullWidth="true" %}

```python
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)
```

{% endcode %}

{% hint style="info" %}
Please check all the comments in the code and replace with the required data.
{% endhint %}
{% endtab %}
{% endtabs %}
