Vehicle invoice

1. Extract vehicle invoice information with image URL or pdf URL input

API:

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

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/invoice_vehicle?img=%s&format_type=url&get_thumb=false"
% image_url,
auth=(api_key, api_secret))
print(response.json())

2. Extract vehicle invoice information with image file or pdf file input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/document/invoice_vehiclemultipart/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/invoice_vehicle?format_type=file&get_thumb=false",
auth=(api_key, api_secret),
files={'img': open(image_path, 'rb')})
print(response.json())

3. Extract vehicle invoice information with JSON input

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/ocr/document/invoice_vehicleapplication/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/invoice_vehicle?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": [xxxx],
"errorCode": string,
"errorMessage": string
}

Where the data field is a list, each element in the list corresponds to an invoice page. Each of these elements has the following format:

{
"type": "invoice_vehicle",
"info": [xxxx]
}

The info field will contain the following information:

  • account_bank: This field is a list. Each element contains the following fields:
    • account_no
    • account_no_box
    • account_no_confidence
    • bank
    • bank_box
    • bank_confidence
  • buyer_name
  • buyer_name_box
  • buyer_name_confidence
  • date
  • date_box
  • date_confidence
  • form
  • form_box
  • form_confidence
  • image
  • image_table
  • invoice_no
  • invoice_no_box
  • invoice_no_confidence
  • lookup_code
  • lookup_code_box
  • lookup_code_confidence
  • lookup_website
  • lookup_website_box
  • lookup_website_confidence
  • payment_method
  • payment_method_box
  • payment_method_confidence
  • purchaser_name
  • purchaser_name_box
  • purchaser_name_confidence
  • serial_no
  • serial_no_box
  • serial_no_confidence
  • sub_total
  • sub_total_box
  • sub_total_confidence
  • supplier
  • supplier_box
  • supplier_confidence
  • supplier_address
  • supplier_address_box
  • supplier_address_confidence
  • table: This field is a list. Each element contains the following fields:
    • value
    • box
    • score
    • label: Can be one of the following values:
      • number
      • description
      • unit
      • quantity
      • unit_price
      • amount_before_tax
      • tax
      • tax_amount
      • amount_total
  • tax_code
  • tax_code_box
  • tax_code_confidence
  • total_amount
  • total_amount_box
  • total_amount_confidence
  • vat_amount
  • vat_amount_box
  • vat_amount_confidence
  • vat_rate
  • vat_rate_box
  • vat_rate_confidence

Error code table:

CodeMessage
0Success
1The photo does not contain content
2Url is unavailable
3Incorrect image format
4Out of requests
5Incorrect api_key or api_secret
6Incorrect format type