General Invoice OCR
Extract General Invoice Information
Response Definition
HTTP Status | Code | Message | Description |
---|---|---|---|
200 | - | - | OCR success. |
206 | partial_content | Partial content | Some page of request is invalid |
400 | bad_request | Bad request | The API cannot recognize the request with an unspecified cause. |
Parameters
Body
Key | Type | Description |
---|---|---|
image | String | Base64 image encoded stringBase64 image encoded string |
Extract General Invoice Information
POST https://apis.aigen.online/aiscript/general-invoice/v2
Request Body
Name | Type | Description |
---|---|---|
image* | String | Input base64 images encoded utf-8 |
request_id | String | (Optional) Request id manually assigned by a user |
- 200: OK Successful Response
- 206: Partial Content Partial content
- 400: Bad Request Bad Request
{
{
"status": "success",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [],
"data": [
{
"shipping_from_address": {},
"type_doc": {
"value": "ใบสั่งซื้อ",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[
673,
229
],
[
745,
229
],
[
745,
254
],
[
673,
254
]
]
],
"bboxes_norm": [
[
[
0.4069,
0.0979
],
[
0.4504,
0.0979
],
[
0.4504,
0.1086
],
[
0.4069,
0.1086
]
]
],
"confidence": 0.9889107698097206
},
"seller_address": {
"value": "1 64/14 ซ.สุขุมวิท 75 ถ.สุขุวิท แขวงพระโขนงเหนือ กรุงเทพมหานคร",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[
155,
322
],
[
831,
322
],
[
831,
371
],
[
155,
371
]
]
],
"bboxes_norm": [
[
[
0.0937,
0.1377
],
[
0.5024,
0.1377
],
[
0.5024,
0.1586
],
[
0.0937,
0.1586
]
]
],
"table_data": [
[
{
"column": "table_item_number",
"value": "1",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[
147,
577
],
[
158,
577
],
[
158,
588
],
[
147,
588
]
]
],
"bboxes_norm": [
[
[
0.0889,
0.2467
],
[
0.0955,
0.2467
],
[
0.0955,
0.2514
],
[
0.0889,
0.2514
]
]
],
"confidence": 0.9984912923157658
},
{
"column": "table_item_code",
"value": "CON-800138",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[
231,
570
],
[
348,
570
],
[
348,
591
],
[
231,
591
]
]
],
"bboxes_norm": [
[
[
0.1397,
0.2437
],
[
0.2104,
0.2437
],
[
0.2104,
0.2527
],
[
0.1397,
0.2527
]
]
],
"confidence": 0.9859116532963199
}
]
]
}
}
]
}
{
"status": "error",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [
{
"object": "error",
"code": "partial_content",
"message": "Partial content"
}
],
"data": [
{
"shipping_from_address": {},
"buyer_phone_number": {
"value": "0-2693-0460",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[515, 554],
[662, 554],
[662, 579],
[515, 579]
]
],
"bboxes_norm": [
[
[0.3116, 0.2369],
[0.4005, 0.2369],
[0.4005, 0.2475],
[0.3116, 0.2475]
]
],
"confidence": 0.9206300792724775
},
"type_doc": {
"value": "ใบเสร็จรับเงิน/ใบกำกับภาษี",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[636, 67],
[1007, 67],
[1007, 109],
[636, 109]
]
],
"bboxes_norm": [
[
[0.3848, 0.0286],
[0.6092, 0.0286],
[0.6092, 0.0466],
[0.3848, 0.0466]
]
],
"confidence": 0.9689840272880943
},
"table_data": [
[
{
"column": "table_item_number",
"value": "1",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[44, 718],
[60, 718],
[60, 734],
[44, 734]
]
],
"bboxes_norm": [
[
[0.0266, 0.307],
[0.0363, 0.307],
[0.0363, 0.3138],
[0.0266, 0.3138]
]
],
"confidence": 0.9954347511260657
},
{
"column": "table_quantity",
"value": "2.00",
"datetime_iso": "Invalid Datetime",
"bboxes": [
[
[297, 713],
[316, 713],
[316, 738],
[297, 738]
]
],
"bboxes_norm": [
[
[0.1797, 0.3048],
[0.1912, 0.3048],
[0.1912, 0.3155],
[0.1797, 0.3155]
]
],
"confidence": 0.9937440940538345
}
]
]
}
]
}
{
"status": "error",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [
{
"object": "error",
"code": "bad_request",
"message": "Bad Request"
}
],
"data": []
}
- Python
- Nodejs
- PHP
- CURL
import requests
api = "https://apis.aigen.online/aiscript/general-invoice/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/general-invoice/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/general-invoice/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/general-invoice/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>",
}'