Vehicle quotes
1. Extract vehicle quote information with photo URL input
API:
| Method | URL | 
|---|---|
| GET | https://demo.computervision.com.vn/api/v2/ocr/document/price_quotation | 
Params:
| Key | Value | Description | 
|---|---|---|
| img | https://example.com/image.png | URL of photo | 
| format_type | url | Type of data to pass in, receive value: url,file,base64 | 
| get_thumb | true/false | Returns a aligned image | 
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"image_url = 'https://example.com/image.png'response = requests.get("https://demo.computervision.com.vn/api/v2/ocr/document/price_quotation?img=%s&format_type=url&get_thumb=false"% image_url,auth=(api_key, api_secret))print(response.json())
2. Extract vehicle quote information with image file input
API:
| Method | URL | content-type | 
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/document/price_quotation | multipart/form-data | 
Params:
| Key | Value | Description | 
|---|---|---|
| format_type | file | Type of data to pass in, receive value: url,file,base64 | 
| get_thumb | true/false | Returns a aligned image | 
Body:
| Key | Type | Value | Description | 
|---|---|---|---|
| img | file | example.jpg | Image file or pdf file of vehicle quote to extract information | 
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"image_path = '/path/to/your/image.jpg'response = requests.post("https://demo.computervision.com.vn/api/v2/ocr/document/price_quotation?format_type=file&get_thumb=false",auth=(api_key, api_secret),files={'img': open(image_path, 'rb')})print(response.json())
3. Extract vehicle quote information with JSON input
API:
| Method | URL | content-type | 
|---|---|---|
| POST | https://demo.computervision.com.vn/api/v2/ocr/document/price_quotation | application/json | 
Params:
| Key | Value | Description | 
|---|---|---|
| format_type | base64 | Type of data to pass in, receive value: url,file,base64 | 
| get_thumb | true/false | Returns a aligned image | 
Body:
{"img": "iVBORw0KGgoAAAANSU..." // string base64 of the image or pdf to extract}
Demo Python:
import base64import ioimport requestsfrom PIL import Imagedef 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_imgapi_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://demo.computervision.com.vn/api/v2/ocr/document/price_quotation?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 a vehicle quote (a vehicle quote can be one or more pages). Each of these elements is a JSON formatted as follows:
{"type": "price_quotation","info": [xxxx]}
The info field is a JSON with the following fields:
- estimated_delivery_date
- estimated_delivery_date_box
- estimated_delivery_date_confidence
- image
- image_table
- make_model
- make_model_box
- make_model_confidence
- name_of_garage
- name_of_garage_box
- name_of_garage_confidence
- number_plate
- number_plate_box
- number_plate_confidence
- quotation_date
- quotation_date_box
- quotation_date_confidence
- sub_total
- sub_total_box
- sub_total_confidence
- table: As a list, each element in the list contains information for a row. Each of these elements is a JSON containing the following information:- amount_total
- amount_total_box
- amount_total_confidence
- description
- description_box
- description_confidence
- discount
- discount_box
- discount_confidence
- percent_discount
- percent_discount_box
- percent_discount_confidence
- quantity
- quantity_box
- quantity_confidence
- tax
- tax_box
- tax_confidence
- unit_price
- unit_price_box
- unit_price_confidence
 
- total_amount
- total_amount_box
- total_amount_confidence
- vat_amount
- vat_amount_box
- vat_amount_confidence
Error code table:
| Code | Message | 
|---|---|
| 0 | Success | 
| 1 | The photo does not contain content | 
| 2 | Url is unavailable | 
| 3 | Incorrect image format | 
| 4 | Out of requests | 
| 5 | Incorrect api_key or api_secret | 
| 6 | Incorrect format type |