Skip to main content

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 StatusStatusMessageDescription
200success-OCR success.
206errorPartial Content.Some pages succeed, some pages fail.
400errorDocument page to large (support 30 page/request)Too many pages (>30) in one request.
400errorBad requestNo page could be processed successfully.
413errorThe request image base64 is too large.Payload exceeds service size limit.
415errorThe base64 image is incompatible.Invalid or unsupported base64 image/PDF payload.
422-Validation ErrorInvalid request body schema (e.g., missing image or wrong type).

Parameters

Body

KeyTypeDescription
imagestringBase64-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

NameTypeDescription
image*stringInput base64 image encoded in UTF-8.

Response Schema

Top-level response

KeyTypeDescription
statusstringOverall processing status: success or error.
errorlist[ErrorObject]List of request-level and/or page-level errors. Empty when all pages succeed.
datalist[PageResult | {}]One item per processed page. Failed pages may be represented as empty object {}.

ErrorObject schema

KeyTypeDescription
objectstringAlways error.
codestring | intError code (e.g., "400", "206", 20000, 20001).
messagestringHuman-readable error description.

PageResult schema

KeyTypeDescription
statusintPage-level status code (typically 200 for successful page extraction).
account_nameFieldResult | {}Account holder name.
account_numberFieldResult | {}Account number.
bank_nameFieldResult | {}Bank name.
ocr_textobjectHeader OCR field (currently normalized to empty object {} in V4).
bring_forwardobjectForward field (currently normalized to {}).
credit_forwardobjectForward field (currently normalized to {}).
debit_forwardobjectForward field (currently normalized to {}).
tablelist[TransactionRow]Extracted transaction rows for the page.
credit_summaryFieldResult | {}Summed credit amount for the page after normalization.
debit_summaryFieldResult | {}Summed debit amount for the page after normalization.

TransactionRow schema

KeyTypeDescription
dateFieldResultNormalized transaction date text.
codeFieldResultDEBIT or CREDIT.
debitFieldResultDebit amount text (normalized string form).
creditFieldResultCredit amount text (normalized string form).
balanceFieldResultBalance amount text (normalized string form).
row_confFieldResultRow confidence (currently defaulted to 0.9).
ocr_textFieldResultTransaction OCR text for the row.

FieldResult schema

KeyTypeDescription
valuestring | int | floatExtracted/normalized field value.
bboxeslistBounding-box container (V4 currently returns empty list []).

Notes

  • 422 validation responses are generated by FastAPI/Pydantic and follow a detail array schema, not the normal {status,error,data} envelope.
  • Response header x-aigen-usage-unit is set to the number of input pages processed in the request.
{
"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": []
}
}
]
}
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())