Payslip OCR
API Documentation for Payslip OCR
Response Definition
HTTP Status | Code | Message | Description |
---|---|---|---|
200 | - | success | OCR success. |
206 | partial_content | partial content | Some pages might not be a valid payslip document. |
400 | bad_request | Bad Request | Not a valid base64 image request (must be .jpg, .jpeg, .png, .pdf) or invalid size, request schema. |
413 | request_entity_too_large | Request entity too large | Request image’s size is too large. |
500 | internal_server_error | Internal server error | some errors occur at the server side. |
Extract Shipping Invoice Information
POST https://apis.aigen.online/aiscript/payslip/v2
Request Body
Name | Type | Description |
---|---|---|
image* | String | Base64 image encoded stringBase64 image encoded string |
- 200: OK success
- 206: Partial Content Partial content
- 400: Bad Request Bad Request
- 413: Payload Too Large Request Entity Too Large
- 500: Internal Server Error Internal Server Error
{'response_id': '',
'status': 'success',
'error': [],
'data': [{'name': {'value': 'Chaiyasit',
'bboxes': [[[756, 355], [1332, 355], [1332, 406], [756, 406]]],
'bboxes_norm': [[[0.3048, 0.1012],
[0.5371, 0.1012],
[0.5371, 0.1158],
[0.3048, 0.1158]]],
'confidence': 0.9627},
'lastname': {'value': 'Kumtornkittikul',
'bboxes': [[[756, 355], [1332, 355], [1332, 406], [756, 406]]],
'bboxes_norm': [[[0.3048, 0.1012],
[0.5371, 0.1012],
[0.5371, 0.1158],
[0.3048, 0.1158]]],
'confidence': 0.9833},
'company_name': {'value': 'Mitsubishi Electric Factory Automation (Thailand) MlecTac Charges for the Better Co.,Ltd.',
'bboxes': [[[306, 164], [1360, 164], [1360, 234], [306, 234]],
[[1742, 125], [1968, 125], [1968, 258], [1742, 258]],
[[1626, 222], [1957, 222], [1957, 288], [1626, 288]],
[[750, 251], [921, 251], [921, 326], [750, 326]]],
'bboxes_norm': [[[0.1234, 0.0468],
[0.5484, 0.0468],
[0.5484, 0.0667],
[0.1234, 0.0667]],
[[0.7024, 0.0356], [0.7935, 0.0356], [0.7935, 0.0736], [0.7024, 0.0736]],
[[0.6556, 0.0633], [0.7891, 0.0633], [0.7891, 0.0821], [0.6556, 0.0821]],
[[0.3024, 0.0716], [0.3714, 0.0716], [0.3714, 0.093], [0.3024, 0.093]]],
'confidence': 0.7891},
…
{'response_id': '',
'status': 'error',
'error': [{'object': 'error',
'code': 'Not_a_valid_payslip',
'message': 'Not a valid payslip'},
{'object': 'error',
'code': 'partial_content',
'message': 'Partial content'}],
'data': [{'name': {'value': 'นายจักราวุร',
'bboxes': [[[387, 444], [593, 444], [593, 478], [387, 478]]],
'bboxes_norm': [[[0.234, 0.1898],
[0.3585, 0.1898],
[0.3585, 0.2044],
[0.234, 0.2044]]],
'confidence': 0.9627},
…
{
"response_id": "",
"status": "error",
"error": [
{
"object": "error",
"code": "Not_a_valid_payslip",
"message": "Not a valid payslip"
},
{
"object": "error",
"code": "bad_request",
"message": "The request is not a payslip or invalid."
}
],
"data": [{}]
}
[{'response_id': '',
'status': 'error',
'error': [{'object': 'error',
'code': 'request_entity_too_large',
'message': 'The request size exceeds the limit (10240 KB)'],
'data': []}]
[{'response_id': '',
'status': 'error',
'error': [{'object': 'error',
'code': internal_server_error',
'message': 'Internal server error on page <#page_no>’,
'data': []}]
- Python
- Nodejs
- PHP
- CURL
import requests
api = "https://apis.aigen.online/aiscript/payslip/v2"
headers = {"x-aigen-key": "<key>"}
data = {"image": "<base64_string>"}
res = requests.post(api, json=data, headers=headers)
print(res.json())
const axios = require("axios");
const api = "https://apis.aigen.online/aiscript/payslip/v2";
const headers = {
"x-aigen-key": "<key>",
};
const data = { image: "<base64_string>" };
axios
.post(api, data, { headers: headers })
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.error(err.response.data);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://apis.aigen.online/aiscript/payslip/v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"image": "<base64_string>",
}',
CURLOPT_HTTPHEADER => array(
'X-AIGEN-KEY: <aigen-key>',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
curl --location 'https://apis.aigen.online/aiscript/payslip/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>",
}'