API Documentation

Bank Book Example (SCB)

test.png
post
https://api.iapp.co.th/book-bank-ocr/lineman/file
/
Bank Book OCR

Sample Requests

CURL
Python
Java - Unirest
C#
NodeJS - Request
Objective C
PHP
1
curl --location --request POST 'https://api.iapp.co.th/book-bank-ocr/lineman/file'
2
--header 'apikey: --- Your API Key ---'
3
--form '[email protected]"/your/path/to/image.jpg"'
Copied!
1
import requests
2
url = "https://api.iapp.co.th/book-bank-ocr/lineman/file"
3
payload={}
4
files=[ ('file',('image.jpg',open('/your/path/to/image.jpg','rb'),'image/jpeg')) ]
5
headers = { 'apikey': '--- Your API Key ---' }
6
response = requests.request("POST", url, headers=headers, data=payload, files=files)
7
print(response.text)
Copied!
1
Unirest.setTimeouts(0, 0);
2
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/book-bank-ocr/lineman/file")
3
.header("apikey", "--- Your API Key ---")
4
.field("file", new File("/your/path/to/image.jpg"))
5
.asString();
Copied!
1
var client = new RestClient("https://api.iapp.co.th/book-bank-ocr/lineman/file");
2
client.Timeout = -1;
3
var request = new RestRequest(Method.POST);
4
request.AddHeader("apikey", "--- Your API Key ---");
5
request.AddFile("file", "/your/path/to/image.jpg");
6
IRestResponse response = client.Execute(request);
7
Console.WriteLine(response.Content);
Copied!
1
var request = require('request');
2
var fs = require('fs');
3
var options = {
4
'method': 'POST',
5
'url': 'https://api.iapp.co.th/book-bank-ocr/lineman/file',
6
'headers': {
7
'apikey': '--- Your API Key ---'
8
},
9
formData: {
10
'file': {
11
'value': fs.createReadStream('/your/path/to/image.jpg'),
12
'options': {
13
'filename': 'image.jpg',
14
'contentType': null
15
}
16
}
17
}
18
};
19
request(options, function (error, response) {
20
if (error) throw new Error(error);
21
console.log(response.body);
22
});
Copied!
1
#import <Foundation/Foundation.h>
2
3
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
4
5
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/book-bank-ocr/lineman/file"]
6
cachePolicy:NSURLRequestUseProtocolCachePolicy
7
timeoutInterval:10.0];
8
NSDictionary *headers = @{
9
@"apikey": @"--- Your API Key ---"
10
};
11
12
[request setAllHTTPHeaderFields:headers];
13
NSArray *parameters = @[
14
@{ @"name": @"file", @"fileName": @"/your/path/to/image.jpg" }
15
];
16
17
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
18
NSError *error;
19
NSMutableString *body = [NSMutableString string];
20
21
for (NSDictionary *param in parameters) {
22
[body appendFormat:@"--%@\r\n", boundary];
23
if (param[@"fileName"]) {
24
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
25
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
26
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
27
if (error) {
28
NSLog(@"%@", error);
29
}
30
} else {
31
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
32
[body appendFormat:@"%@", param[@"value"]];
33
}
34
}
35
[body appendFormat:@"\r\n--%@--\r\n", boundary];
36
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
37
[request setHTTPBody:postData];
38
39
[request setHTTPMethod:@"POST"];
40
41
NSURLSession *session = [NSURLSession sharedSession];
42
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
43
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
44
if (error) {
45
NSLog(@"%@", error);
46
dispatch_semaphore_signal(sema);
47
} else {
48
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
49
NSError *parseError = nil;
50
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
51
NSLog(@"%@",responseDictionary);
52
dispatch_semaphore_signal(sema);
53
}
54
}];
55
[dataTask resume];
56
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
Copied!
1
<?php
2
require_once 'HTTP/Request2.php';
3
$request = new HTTP_Request2();
4
$request->setUrl('https://api.iapp.co.th/book-bank-ocr/lineman/file');
5
$request->setMethod(HTTP_Request2::METHOD_POST);
6
$request->setConfig(array(
7
'follow_redirects' => TRUE
8
));
9
$request->setHeader(array(
10
'apikey' => '--- Your API Key ---'
11
));
12
$request->addUpload('file', '/your/path/to/image.jpg', 'image.jpg', '<Content-Type Header>');
13
try {
14
$response = $request->send();
15
if ($response->getStatus() == 200) {
16
echo $response->getBody();
17
}
18
else {
19
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
20
$response->getReasonPhrase();
21
}
22
}
23
catch(HTTP_Request2_Exception $e) {
24
echo 'Error: ' . $e->getMessage();
Copied!

Parameters

Fields
Description
Bank Name
Name of the bank
Account Number
Account number on the bank book
Account Name
Account name on the bank book
Bank Branch
Name of the bank branch

Return Values

Fields
Type
Description
message
string
OCR successful / unsuccessful
status
int
API code
file-name-bookbank
string
Name of the input file
bank_name
string
Name of the bank
account_number
string
Account number on the bank book
account_name
string
Account name on the bank book
bank_branch
string
Name of the bank branch
signature
string
signature on the bank book
final-reason-codes
dict
Reason for detection failures
confidence
float
Average confidence of the OCR
inference
float
Time taken to process bank book

final-reason-codes (dict)

Fields
Type
Description
final_code
int
0 (manual check) or 1(pass)
message
string
pass or manual check
reason_codes
dict
reason codes f bank book fields and signature

reason_codes (dict)

Fields
Type
Description
reason_code_bookbank
int
0 or 1
reason_code_bookbank_signature
int
0 or 1
reason_codename_bookbank_signature
string
Reason if signature not found