Документация
VeriDoc WEB API

RECOGNITION_URL=https://www.verigram.kz/ru/veridoc/

YOUR_USER='your_username'

YOUR_PASS='your_password'

DOCUMENT_TYPE=1    # for identity card documents


response=$(curl $RECOGNITION_URL \

  -F username=$YOUR_USER \

  -F password=$YOUR_PASS \

  -F "image=@/path/to/image" \

  -F image_id=1 -F doc_type=$DOCUMENT_TYPE \

  -F biggerImage=true)


echo $response


LOGIN_URL=https://www.verigram.kz/ru/veridoc/login/

RECOGNITION_URL=https://www.verigram.kz/ru/veridoc/

YOUR_USER='username'

YOUR_PASS='password'

COOKIES=cookies.txt

DOCUMENT_TYPE=1    # for identity card documents


CURL_BIN="curl -s -c $COOKIES -b $COOKIES -e $LOGIN_URL"


$CURL_BIN $LOGIN_URL > /dev/null

DJANGO_TOKEN="csrfmiddlewaretoken=$(grep csrftoken $COOKIES | sed 's/^.*csrftoken\s*//')"


$CURL_BIN -d "$DJANGO_TOKEN&username=$YOUR_USER&password=$YOUR_PASS" \

$LOGIN_URL


echo "Request started ..."

response=$(curl \

-b $COOKIES $RECOGNITION_URL \

-F "image=@/path/to/image" -F image_id=1 -F doc_type=$DOCUMENT_TYPE \

-F biggerImage=true)

echo $response

               

  • "image=@/path/to/image" - путь к изображению на локальном компьютере.

  • image_id – номер распознаваемого изображения (всегда равен 1).

  • doc_type – номер типа документа (1 - удостоверение личности, 17 - водительские права, 20 - техпаспорт автомобиля, 28 - МРЗ зона).

  • biggerImage – флаг для обозначения полного распознавания (всегда true).

  • username – имя пользователя.

  • password – пароль для этого пользователя.


Successful response:

HTTP/1.1 200 OK

{

"last_name": "ИВАНОВ", // All uppercase

"first_name": "ИВАН",

"middle_name": "ИВАНОВИЧ",

"birth_date": "31011999", // DDMMYYYY

"iin": "990131600046",

"face_picture": "...",    // base64 encoded jpeg image

"signature_picture": "..." // base64 encoded jpeg image

}


Unsuccessful response:

HTTP/1.1 400

{

"error": "..." // error message

}



Successful response:

HTTP/1.1 200 OK

{

"id_number": "037462607",

"birth_place": "АЛМАТЫ",

"nationality": "КАЗАХ",

"issuer": "МВД РЕСПУБЛИКИ КАЗАХСТАН",

"issue_date": "20012015",

"due_date": "19012025"

}



{

"id_number": "ASNE00З81З96",

"registration_number": "7ЗЗYHAO2", 

"brand": "BKИVV52ЗI",

"issue_date": "2014",

"category": "B, C, B1",

"vin_number": "VVBALPЗ100AC5012З2", 

"body": "VVBALPЗ100AC5012З2", 

"chassis": "",

"manufacturer": "Зарубежное", 

"color": "Белый Металлик", "engine_capacity": "24153", "max_weight": "2200", "weight_without_load": "1800"

}


Обратная сторона


{

"last_name": "Литтиг/Littig",

 "first_name": "Игорь Владимирович/Igor", 

"state": "Алматы", 

"district": "Ауэзовский Район", 

"locality": "г.Алматы", 

"street": "Таугуль-1", 

"house": "67", 

"apartment": "31", 

"issue_date": "26.02.2016", 

"id_number": "AS № 00328907"

}


Водительское удостоверение


{

"last_name": "ИВАНОВ", // All uppercase

"first_name": "ИВАН",

"middle_name": "ИВАНОВИЧ",

"birth_date": "31011999", // DDMMYYYY

"birth_place": "Алматы",

"issue_date": "20012015",

"due_date": "19012025",

“dia”:”ІІД АЛМАТЫ Қ.$DIA OF ALMATY”

"iin": "990131600046",

“id_number”:”AN № 789065”,

"face_picture": "...",    // base64 encoded jpeg image

}


Приложение 1

Пример запроса на языке C#:


public void reqVeri(string img) {

    // Create a http request to the server endpoint that will pick up the

    // file and file description.

    HttpWebRequest requestToServerEndpoint =

    (HttpWebRequest)WebRequest.Create("https://www.verigram.kz/ru/veridoc/");

    string boundaryString = "----SomeRandomText";

    string fileUrl = @"C:\Address\To\Document.jpg";

    // Set the http request header \\

    requestToServerEndpoint.Method = WebRequestMethods.Http.Post;

    requestToServerEndpoint.ContentType = "multipart/form-data; boundary=" + boundaryString;

    requestToServerEndpoint.KeepAlive = true;

    requestToServerEndpoint.Credentials = System.Net.CredentialCache.DefaultCredentials;

    // Use a MemoryStream to form the post data request,

    // so that we can get the content-length attribute.

    MemoryStream postDataStream = new MemoryStream();

    StreamWriter postDataWriter = new StreamWriter(postDataStream);

   

    // Include value from the myFileDescription text area in the post data

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",

    "username",

    "ВАШ ЛОГИН");

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",

    "password",

    "ВАШ ПАРОЛЬ");

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",

    "image_id",

    1);

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",

    "biggerImage",

    true);

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",

    "doc_type",

    "1"); // change doc_type to needed number

    // Include the file in the post data

    postDataWriter.Write("\r\n--" + boundaryString + "\r\n");

    postDataWriter.Write("Content-Disposition: form-data;"

    + "name=\"{0}\";"

    + "filename=\"{1}\""

    + "\r\nContent-Type: {2}\r\n\r\n",

    "image",

    Path.GetFileName(fileUrl),

    Path.GetExtension(fileUrl));

    postDataWriter.Flush();

    // Read the file

    FileStream fileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);

    byte[] buffer = new byte[1024];

    int bytesRead = 0;

    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)

    {

        postDataStream.Write(buffer, 0, bytesRead);

    }

    fileStream.Close();

    postDataWriter.Write("\r\n--" + boundaryString + "--\r\n");

    postDataWriter.Flush();

   

    requestToServerEndpoint.ContentLength = postDataStream.Length;

   

    using (Stream s = requestToServerEndpoint.GetRequestStream())

    {

        postDataStream.WriteTo(s);

    }

    postDataStream.Close();

   

    WebResponse response = requestToServerEndpoint.GetResponse();

    StreamReader responseReader = new StreamReader(response.GetResponseStream());

    string replyFromServer = responseReader.ReadToEnd();

}



Пример запроса на языке JavaScript на веб странице:


<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

  <title>Test</title>

</head>

<body>

  <form class="input-group" id="img2b64">

      <input id="inputFileToLoad" type="file" onchange="encodeImageFileAsURL();" />

  </form>


  <p id="result"><p>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot;&gt;&lt;/script&gt;

  <script type="text/javascript">

      function encodeImageFileAsURL(cb) {

          return function(){

              var file = this.files[0];

              var reader  = new FileReader();

              reader.onloadend = function () {

                  cb(reader.result);

              }

              reader.readAsDataURL(file);

          }

      }


      $('#inputFileToLoad').change(encodeImageFileAsURL(sendRequestToVeridoc));


      function sendRequestToVeridoc(imageData) {

          const blobBin = atob(imageData.split(',')[1]);

          const array = [];

          for (let j = 0; j < blobBin.length; j += 1) {

              array.push(blobBin.charCodeAt(j));

          }

          const jpegFileBlob = new Blob([new Uint8Array(array)], {

              type: 'image/jpeg',

          });


          var form = new FormData();

          form.append('image', jpegFileBlob, 'upload.jpeg');

          form.append("username", "ВАШ ЛОГИН");

          form.append("password", "ВАШ ПАРОЛЬ");

          form.append("image_id", "1");

          form.append("biggerImage", "true");

          form.append("doc_type", "1"); // change doc_type to needed


          $.ajax({

              type: 'POST',

              data: form,

              contentType: 'multipart/form-data',

              url: 'https://verigram.kz/en/veridoc/',

              contentType: false,

              processData: false,

              success: function(data) {

                  console.log(data);

                  $('#result').text(JSON.stringify(data));

              },

              error: function(data) {

                  console.log('error');

                  $('#result').text('Error occurred');

              }

          })

      }

   </script>

</body>

</html>