Documentation
  • Introduction
  • ⚡Quick Guide
  • APIs
    • 🔑OAuth Token
    • 🆔National ID OCR
      • 🔁API Response
    • ✈️Passport
    • 🇦🇪UAE Resident ID OCR
    • 🧑‍💼Face Match
      • Face Match (Two Images)
      • Face Match (Image & Transaction ID)
    • ✈️Libyan passport
    • 🚗Egyptian Car License
    • 🇲🇦Moroccan Documents OCR
      • 🆔Moroccan National ID (MRZ & Barcode)
      • ✈️Moroccan Passport
      • 🗂️Moroccan Residency Card
      • 🚗Moroccan Driving 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
  1. APIs
  2. Moroccan Documents OCR

Moroccan Driving License


This API provides Data Extraction for Moroccan Driving License documents.

Moroccan Driving License 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_driver_license

data

object

Object containing the parameters below: { "img": , # optional default is "" "bundle_key": , "lang": # optional default is ""}

Please note thatimg cannot be empty (i.e., missing or an empty string "").

{
    "result": {
        "first_name": {
            "arabic": <string>,
            "latin": <string>
        },
        "last_name": {
            "arabic": <string>,
            "latin": <string>
        },
        "issue_city": {
            "arabic": <string>,
            "latin": <string>
        },
        "issue_place_v2_license": {
            "arabic": <string>,
            "latin": <string>
        },
        "birth_place": {
            "arabic": <string>,
            "latin": <string>
        },
        "issue_date": <string>,
        "expiry_date": <string>,
        "birth_date": <string>,
        "issue_place_v1_license": <string>,
        "code": <string>,
        "id_num": <string>,
        "card_num": <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"
}

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_driver_license', 
    'data':
    {   
        'img': <'passport_base_64_img'>
        '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())
PreviousMoroccan Residency CardNextTransliteration

Last updated 13 days ago

🇲🇦
🚗