Bank Statement OCR
Extract Bank Statement information from an image or PDF.
API Version
Bank Statement OCR
Extract Bank Statement information from an image or PDF.
Response Definition
| HTTP Status | Status | Message | Description |
|---|---|---|---|
| 200 | success | - | OCR success. |
| 206 | error | Partial Content. | Some pages succeed, some pages fail. |
| 400 | error | Document page to large (support 30 page/request) | Too many pages (>30) in one request. |
| 400 | error | Bad request | No page could be processed successfully. |
| 413 | error | The request image base64 is too large. | Payload exceeds service size limit. |
| 415 | error | The base64 image is incompatible. | Invalid or unsupported base64 image/PDF payload. |
| 422 | - | Validation Error | Invalid request body schema (e.g., missing image or wrong type). |
Parameters
Body
| Key | Type | Description |
|---|---|---|
image | string | Base64-encoded image or PDF payload. Supports single image or multi-page PDF (up to 30 pages per request). |
Extract Bank Statement Information
POST https://api.aigen.online/aiscript/bank-statement/v4
Request Body
| Name | Type | Description |
|---|---|---|
image* | string | Input base64 image encoded in UTF-8. |
Response Schema
Top-level response
| Key | Type | Description |
|---|---|---|
status | string | Overall processing status: success or error. |
error | list[ErrorObject] | List of request-level and/or page-level errors. Empty when all pages succeed. |
data | list[PageResult | {}] | One item per processed page. Failed pages may be represented as empty object {}. |
ErrorObject schema
| Key | Type | Description |
|---|---|---|
object | string | Always error. |
code | string | int | Error code (e.g., "400", "206", 20000, 20001). |
message | string | Human-readable error description. |
PageResult schema
| Key | Type | Description |
|---|---|---|
status | int | Page-level status code (typically 200 for successful page extraction). |
account_name | FieldResult | {} | Account holder name. |
account_number | FieldResult | {} | Account number. |
bank_name | FieldResult | {} | Bank name. |
ocr_text | object | Header OCR field (currently normalized to empty object {} in V4). |
bring_forward | object | Forward field (currently normalized to {}). |
credit_forward | object | Forward field (currently normalized to {}). |
debit_forward | object | Forward field (currently normalized to {}). |
table | list[TransactionRow] | Extracted transaction rows for the page. |
credit_summary | FieldResult | {} | Summed credit amount for the page after normalization. |
debit_summary | FieldResult | {} | Summed debit amount for the page after normalization. |
TransactionRow schema
| Key | Type | Description |
|---|---|---|
date | FieldResult | Normalized transaction date text. |
code | FieldResult | DEBIT or CREDIT. |
debit | FieldResult | Debit amount text (normalized string form). |
credit | FieldResult | Credit amount text (normalized string form). |
balance | FieldResult | Balance amount text (normalized string form). |
row_conf | FieldResult | Row confidence (currently defaulted to 0.9). |
ocr_text | FieldResult | Transaction OCR text for the row. |
FieldResult schema
| Key | Type | Description |
|---|---|---|
value | string | int | float | Extracted/normalized field value. |
bboxes | list | Bounding-box container (V4 currently returns empty list []). |
Notes
422validation responses are generated by FastAPI/Pydantic and follow adetailarray schema, not the normal{status,error,data}envelope.- Response header
x-aigen-usage-unitis set to the number of input pages processed in the request.
- 200: OK Successful Response
- 206: Partial content
- 400: Too many pages in one request
- 400: Bad request (no page succeeds)
- 413: Request payload too large
- 415: Invalid or unsupported base64 image payload
- 422: Invalid request body
{
"status": "success",
"error": [],
"data": [
{
"status": 200,
"account_name": {
"value": "Example Account Holder",
"bboxes": []
},
"account_number": {
"value": "XXX-X-XXXXX-X",
"bboxes": []
},
"bank_name": {
"value": "Example Bank",
"bboxes": []
},
"bring_forward": {},
"credit_forward": {},
"debit_forward": {},
"table": [
{
"date": {
"value": "27/02/2021",
"bboxes": []
},
"code": {
"value": "DEBIT",
"bboxes": []
},
"debit": {
"value": "5000.00",
"bboxes": []
},
"credit": {
"value": "",
"bboxes": []
},
"balance": {
"value": "97913.71",
"bboxes": []
},
"row_conf": {
"value": "0.9",
"bboxes": []
},
"ocr_text": {
"value": "27/02/2021 ถอนโดยการโอน 5,000.00 97,913.71 MOBILE",
"bboxes": []
}
},
{
"date": {
"value": "28/02/2021",
"bboxes": []
},
"code": {
"value": "CREDIT",
"bboxes": []
},
"debit": {
"value": "",
"bboxes": []
},
"credit": {
"value": "800.00",
"bboxes": []
},
"balance": {
"value": "98713.71",
"bboxes": []
},
"row_conf": {
"value": "0.9",
"bboxes": []
},
"ocr_text": {
"value": "28/02/2021 ฝากโดยการโอน 800.00 98,713.71 9921WM8",
"bboxes": []
}
},
{
"date": {
"value": "29/02/2021",
"bboxes": []
},
"code": {
"value": "CREDIT",
"bboxes": []
},
"debit": {
"value": "",
"bboxes": []
},
"credit": {
"value": "2500.00",
"bboxes": []
},
"balance": {
"value": "101213.71",
"bboxes": []
},
"row_conf": {
"value": "0.9",
"bboxes": []
},
"ocr_text": {
"value": "29/02/2021 ฝากโดยการโอน 2500.00 101213.71 9996WMB",
"bboxes": []
}
}
],
"credit_summary": {
"value": "3300",
"bboxes": []
},
"debit_summary": {
"value": "5000",
"bboxes": []
}
}
]
}
{
"status": "error",
"error": [
{
"object": "error",
"code": "206",
"message": "Partial Content."
}
],
"data": [
{
"status": 200,
"account_name": {
"value": "Example Account Holder",
"bboxes": []
},
"account_number": {
"value": "XXX-X-XXXXX-X",
"bboxes": []
},
"bank_name": {
"value": "Example Bank",
"bboxes": []
},
"bring_forward": {},
"credit_forward": {},
"debit_forward": {},
"table": [],
"credit_summary": {
"value": "",
"bboxes": []
},
"debit_summary": {
"value": "",
"bboxes": []
}
},
{}
]
}
{
"status": "error",
"error": [
{
"object": "error",
"code": "400",
"message": "Document page to large (support 30 page/request)"
}
],
"data": []
}
{
"status": "error",
"error": [
{
"object": "error",
"code": "400",
"message": "Bad request"
}
],
"data": []
}
{
"status": "error",
"error": [
{
"object": "error",
"code": 20000,
"message": "The request image base64 is too large."
}
],
"data": []
}
{
"status": "error",
"error": [
{
"object": "error",
"code": 20001,
"message": "The base64 image is incompatible."
}
],
"data": []
}
{
"detail": [
{
"loc": ["body", "image"],
"msg": "Field required",
"type": "missing"
}
]
}
- Python
- Nodejs
- PHP
- CURL
import requests
api = "https://api.aigen.online/aiscript/bank-statement/v4"
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://api.aigen.online/aiscript/bank-statement/v4";
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://api.aigen.online/aiscript/bank-statement/v4',
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://api.aigen.online/aiscript/bank-statement/v4' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>"
}'