https://verigram.kz/en/veridoc/ - send a POST request with a photo ID
Content-Type: multipart/form-data
There are 2 ways to send an image for recognition:
Method 1:
Sending POST requests with authorization data. An example of a request using the CURL utility (examples of requests in some programming languages can be found in Appendix 1):
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
Method 2:
Before sending requests for recognition, you need to log in to the page https://verigram.kz/en/veridoc/login/. This is needed to create a session for this user. After that, we can send requests to the page https://verigram.kz/en/veridoc/with several mandatory parameters and session data. An example BASH script for a request using the curl utility:
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" - path to the image on the local computer.
-
image_id – number of the recognized image (always equal to 1).
-
doc_type – document type number (1 - identity card, 17 - driver's license, 20 - vehicle registration certificate, 28 - MRZ zone).
-
biggerImage – flag to indicate full recognition (always 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
}
https://verigram.kz/en/veridoc/ - the same for the back of the identity. The system detects the side and the corresponding fields automatically
Successful response:
HTTP/1.1 200 OK
{
"id_number": "037462607",
"birth_place": "АЛМАТЫ",
"nationality": "КАЗАХ",
"issuer": "МВД РЕСПУБЛИКИ КАЗАХСТАН",
"issue_date": "20012015",
"due_date": "19012025"
}
https://verigram.kz/en/veridoc/ - the same for the data sheet. The system detects the side and the corresponding fields automatically
Front side
{
"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"
}
Back side
{
"last_name": "Литтиг/Littig",
"first_name": "Игорь Владимирович/Igor",
"state": "Алматы",
"district": "Ауэзовский Район",
"locality": "г.Алматы",
"street": "Таугуль-1",
"house": "67",
"apartment": "31",
"issue_date": "26.02.2016",
"id_number": "AS № 00328907"
}
Driver's license
{
"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
}
Appendix 1
An example of a request in 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();
}
An example of a JavaScript request on a web page:
<!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"></script>
<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>