Links

Version 3.4

Thai National ID Card Front Side

post
https://api.iapp.co.th
/thai-national-id-card/v3/front
Thai National ID Card Front Side

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python

Default

curl --location --request POST 'https://api.iapp.co.th/thai-national-id-card/v3/front' \
--header 'apikey: {Your API Key}'\
--form 'file=@"APIs/Thai National ID Card OCR v3/id-card-front.jpg"'

Use Options and fields parameter

curl --location --request POST 'https://api.iapp.co.th/thai-national-id-card/v3/front' \
--header 'apikey: {Your API Key}'\
--form 'file=@"APIs/Thai National ID Card OCR v3/id-card-front.jpg"' \
--form 'fields="id_number"' \
--form 'options="fast,grey_check,id_check,spell_check"'

Default

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/thai-national-id-card/v3/front")
.header("apikey", "{Your API Key}")
.field("file", new File("APIs/Thai National ID Card OCR v3/id-card-front.jpg"))
.asString();

Use Options and fields parameter

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/thai-national-id-card/v3/front")
.header("apikey", "{Your API Key}")
.field("file", new File("APIs/Thai National ID Card OCR v3/id-card-front.jpg"))
.field("fields", "id_number")
.field("options", "fast,grey_check,id_check,spell_check")
.asString();

Default

var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/thai-national-id-card/v3/front',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
'file': {
'value': fs.createReadStream('APIs/Thai National ID Card OCR v3/id-card-front.jpg'),
'options': {
'filename': 'id-card-front.jpg',
'contentType': null
}
}
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Use Options and fields parameter

var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/thai-national-id-card/v3/front',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
'file': {
'value': fs.createReadStream('APIs/Thai National ID Card OCR v3/id-card-front.jpg'),
'options': {
'filename': 'id-card-front.jpg',
'contentType': null
}
},
'fields': 'id_number',
'options': 'fast,grey_check,id_check,spell_check'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Default

#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/thai-national-id-card/v3/front"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
[request setAllHTTPHeaderFields:headers];
NSArray *parameters = @[
@{ @"name": @"file", @"fileName": @"APIs/Thai National ID Card OCR v3/id-card-front.jpg" }
];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Use Options and fields parameter

#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/thai-national-id-card/v3/front"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
NSArray *parameters = @[
@{ @"name": @"file", @"fileName": @"APIs/Thai National ID Card OCR v3/id-card-front.jpg" } ,
@{ @"name": @"fields", @"value": @"id_number" },
@{ @"name": @"options", @"value": @"fast,grey_check,id_check,spell_check" }
];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/thai-national-id-card/v3/front');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
$request->addUpload('file', 'APIs/Thai National ID Card OCR v3/id-card-front.jpg', 'id-card-front.jpg', '<Content-Type Header>');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

Use Options and fields parameter

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/thai-national-id-card/v3/front');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
$request->addPostParameter(array(
'fields' => 'id_number',
'options' => 'fast,grey_check,id_check,spell_check'
));
$request->addUpload('file', 'APIs/Thai National ID Card OCR v3/id-card-front.jpg', 'id-card-front.jpg', '<Content-Type Header>');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

Default

import requests
url = "https://api.iapp.co.th/thai-national-id-card/v3/front"
payload={}
files=[
('file',('id-card-front.jpg',open('APIs/Thai National ID Card OCR v3/id-card-front.jpg','rb'),'image/jpeg'))
]
headers = {
'apikey': '{Your API Key}'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)

Used Options and fields parameter

import requests
url = "https://api.iapp.co.th/thai-national-id-card/v3/front"
payload = {
'fields': 'id_number',
'options': 'fast,grey_check,id_check,spell_check'
}
files = [
('file',('id-card-front.jpg',open('APIs/Thai National ID Card OCR v3/id-card-front.jpg','rb'),'image/jpeg'))
]
headers = {
'apikey': '{Your API Key}'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)

Optional Parameter

Fields
Options
Field
Description
address
Address on the ID Card
id_number
ID Number on the ID Card
th_name
Thai first name and Thai Surname on the ID Card
en_name
English first name and English Surname on the ID Card
en_fname
English first name on the ID Card
en_lname
English Surname on the ID Card
th_dob
Thai birthday on the ID Card
en_dob
English birthday on the ID Card
th_expire
Thai expire date on the ID Card
en_expire
English expire date on the ID Card
th_issue
Thai issue date on the ID Card
en_issue
English issue date on the ID Card
religion
Religion on the ID Card
Option
Description
fast
Tool for up speed to process in ID Card field
*May reduce the accuracy of ID Number
grey_check
Tool for check color of image
id_check
Tool for check correctness of ID Card Number
spell_check
Tool for check correctness of data in ID Card
*Please filled “grey_check”, ” id_check” , “ spell_check” If use “options” Parameter

Return Values

Name
Type
Description
address
String
Address on the ID card
detection_score
float
Detection score of a related field
district
String
District name on the ID card
en_dob
String
Date of birth, in English
en_expire
String
Date of expiry, in English
en_fname
String
English given name
en_init
String
Name title, in English
en_issue
String
Date of issue, in Thai
en_lname
String
English surname
en_name
String
English given name and surname
error_message
String
Error message
face
String
Base64 character string converted from the image. The size cannot exceed 10 MB.
gender
String
Gender
home_address
String
Home address on the ID card
id_number
String
National ID number
postal_code
String
Postal Code
process_time
String
Processing time (Sec.)
province
String
Province name on the ID card
religion
String
Religion on the ID card
sub_district
String
Sub district name on the ID card
th_dob
String
Date of birth, in Thai
th_expire
String
Date of expiry, in Thai
th_fname
String
Thai given name
th_init
String
Name title, in English
th_issue
String
Date of issue
th_lname
String
Thai surname
th_name
String
Thai given name and surname

Thai National ID Card Back Side

post
https://api.iapp.co.th
/thai-national-id-card/v3/back
Thai National ID Card Back Side

Sample Requests

CURL
Java - Unirest
NodeJS - Request
Objective C
PHP
Python

Default

curl --location --request POST 'https://api.iapp.co.th/thai-national-id-card/v3/back' \
--header 'apikey: {Your API Key}'\
--form 'file=@"APIs/Thai National ID Card OCR v3/id-card-back.jpg"'

Used Options and fields parameter

curl --location --request POST 'https://api.iapp.co.th/thai-national-id-card/v3/back' \
--header 'apikey: {Your API Key}'\
--form 'file=@"APIs/Thai National ID Card OCR v3/id-card-back.jpg"' \
--form 'options="fast,grey_check,id_check,spell_check"'

Default

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/thai-national-id-card/v3/back")
.header("apikey", "{Your API Key}")
.field("file", new File("APIs/Tjavahai National ID Card OCR v3/id-card-back.jpg"))
.asString();

Used Options and fields parameter

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/thai-national-id-card/v3/back")
.header("apikey", "{Your API Key}")
.field("file", new File("APIs/Thai National ID Card OCR v3/id-card-back.jpg"))
.field("options", "fast,grey_check,id_check,spell_check")
.asString();

Default

var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/thai-national-id-card/v3/back',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
'file': {
'value': fs.createReadStream('APIs/Thai National ID Card OCR v3/id-card-back.jpg'),
'options': {
'filename': 'id-card-back.jpg',
'contentType': null
}
}
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Used Options and fields parameter

var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/thai-national-id-card/v3/back',
'headers': {
'apikey': '{Your API Key}'
},
formData: {
'file': {
'value': fs.createReadStream('APIs/Thai National ID Card OCR v3/id-card-back.jpg'),
'options': {
'filename': 'id-card-back.jpg',
'contentType': null
}
},
'options': 'fast,grey_check,id_check,spell_check'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Default

#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/thai-national-id-card/v3/back"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
[request setAllHTTPHeaderFields:headers];
NSArray *parameters = @[
@{ @"name": @"file", @"fileName": @"APIs/Thai National ID Card OCR v3/id-card-back.jpg" }
];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Used Options and fields parameter

#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/thai-national-id-card/v3/back"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{Your API Key}"
};
NSArray *parameters = @[
@{ @"name": @"file", @"fileName": @"APIs/Thai National ID Card OCR v3/id-card-back.jpg" } ,
@{ @"name": @"options", @"value": @"fast,grey_check,id_check,spell_check" }
];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Default

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/thai-national-id-card/v3/back');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
$request->addUpload('file', 'APIs/Thai National ID Card OCR v3/id-card-back.jpg', 'id-card-back.jpg', '<Content-Type Header>');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}

Used Options and fields parameter

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/thai-national-id-card/v3/back');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{Your API Key}'
));
$request->