Bank statement

1. Extract bank statement information with image URL or pdf URL input

API:

MethodURL
GEThttps://cloud.computervision.com.vn/api/v2/ocr/document/bank_statement

Params:

KeyValueDescription
imghttps://example.com/image.pngURL of photo or pdf
format_typeurlType of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
image_url = 'https://example.com/image.png'
response = requests.get(
"https://cloud.computervision.com.vn/api/v2/ocr/document/bank_statement?img=%s&format_type=url&get_thumb=false"
% image_url,
auth=(api_key, api_secret))
print(response.json())

2. Extract bank statement information with image file or pdf file input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/document/bank_statementmultipart/form-data

Params:

KeyValueDescription
format_typefileType of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Body:

KeyTypeValueDescription
imgfileexample.jpgImage file or pdf file

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
image_path = '/path/to/your/image.jpg'
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/ocr/document/bank_statement?format_type=file&get_thumb=false",
auth=(api_key, api_secret),
files={'img': open(image_path, 'rb')})
print(response.json())

3. Extract bank statement information with JSON input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/document/bank_statementapplication/json

Params:

KeyValueDescription
format_typebase64Type of data to pass in, receive value: url, file, base64
get_thumbtrue/falseReturns a aligned image

Body:

{
"img": "iVBORw0KGgoAAAANSU..." // string base64 of the image or pdf to extract
}

Demo Python:

import base64
import io
import requests
from PIL import Image
def get_byte_img(img):
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format='PNG')
encoded_img = base64.encodebytes(img_byte_arr.getvalue()).decode('ascii')
return encoded_img
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
img_name = "path_img"
encode_cmt = get_byte_img(Image.open(img_name))
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/ocr/document/bank_statement?format_type=base64&get_thumb=false",
auth=(api_key, api_secret),
json={'img' : encode_cmt})
print(response.json())

4. Response

The response will be a JSON with the following format:

{
"data": array,
"errorCode": string,
"errorMessage": string
}

Each element in the data array (corresponding to each extracted page) will be a JSON with the following format:

{
"image_table": array, // List of pictures of the table in the page
"json": array // List of information corresponding to each image in image_table
}

Each element in the json array has the following structure:

[
[json_0, json_1, json_2, json_3, json_4], // Represents each row
[...],
...
]

Each of these json has the following structure:

{
"value": string,
"score": float,
"box": array // [left, top, right, bottom]
}

Error code table:

CodeMessage
0Success
1Incorrect image format
2Url is unavailable
3Incorrect image format
4Incorrect api_key or api_secret
5Out of requests
6Error when processing the request