Domain name for API request: ocr.tencentcloudapi.com.
This API is used to recognize various types of invoices or tickets in an image or PDF file. You can also specify a type. 14 types of standard expense reimbursement invoices are supported, including value-added tax (VAT) invoice (special, general, roll, blockchain, and toll), fully digitalized electronic invoice (special and general), non-tax revenue invoice (general receipt and general payment voucher), quota invoice, general machine-printed invoice, car sales invoice (motor vehicle sales invoice and used car invoice), train ticket, taxi receipt, itinerary/receipt of e-ticket for air transportation, bus ticket, ship ticket, toll receipt, and medical invoice (inpatient and outpatient). This API can also be used for intelligent recognition of other types of invoices. To try now, click here.
A maximum of 5 requests can be initiated per second for this API.
The invoice/ticket subtype (SubType), subtype description (TypeDescription), and parent type (Type) can be returned, as described below:
SubType | TypeDescription | Type |
---|---|---|
VatSpecialInvoice | Special VAT invoice | 3 |
VatCommonInvoice | General VAT invoice | 3 |
VatElectronicCommonInvoice | Electronic general VAT invoice | 3 |
VatElectronicSpecialInvoice | Electronic special VAT invoice | 3 |
VatElectronicInvoiceBlockchain | Blockchain electronic invoice | 3 |
VatElectronicInvoiceToll | Electronic general VAT invoice (toll) | 3 |
VatElectronicSpecialInvoiceFull | Electronic invoice (special) | 16 |
VatElectronicInvoiceFull | Electronic invoice (general) | 16 |
MotorVehicleSaleInvoice | Motor vehicle sales invoice | 12 |
UsedCarPurchaseInvoice | Used car invoice | 12 |
VatInvoiceRoll | General VAT invoice (roll) | 11 |
TaxiTicket | Taxi receipt | 0 |
QuotaInvoice | Quota invoice | 1 |
TrainTicket | Train ticket | 2 |
AirTransport | Itinerary/Receipt of e-ticket for air transportation | 5 |
MachinePrintedInvoice | General machine-printed invoice | 8 |
BusInvoice | Bus ticket | 9 |
ShippingInvoice | Ship ticket | 10 |
NonTaxIncomeGeneralBill | General receipt for non-tax revenue | 15 |
NonTaxIncomeElectronicBill | General payment voucher for non-tax revenue (electronic) | 15 |
TollInvoice | Toll receipt | 13 |
OtherInvoice | Other | -1 |
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: RecognizeGeneralInvoice. |
Version | Yes | String | Common Params. The value used for this API: 2018-11-19. |
Region | No | String | Common Params. This parameter is not required for this API. |
ImageBase64 | No | String | The Base64-encoded value of the image. Supported image formats: PNG, JPG, JPEG, and PDF. GIF is currently not supported. Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s. Supported image pixels: 20 to 10,000 Either ImageUrl or ImageBase64 of the image must be provided. If both are provided, only ImageUrl is used. |
ImageUrl | No | String | The URL of the image. Supported image formats: PNG, JPG, JPEG, and PDF. GIF is currently not supported. Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s. Supported image pixels: 20 to 10,000 We recommend that you store the image in Tencent Cloud for higher download speed and stability. The download speed and stability of non-Tencent Cloud URLs may be low. |
Types.N | No | Array of Integer | The list of the types of invoices to be recognized. If this parameter is left empty, all types of invoices are recognized. 0: Taxi receipt 1: Quota invoice 2: Train ticket 3: VAT invoice 5: Itinerary/Receipt of e-ticket for air transport 8: General machine-printed invoice 9: Bus ticket 10: Ship ticket 11: VAT invoice (roll) 12: Car sales inovice 13: Toll receipt 15: Non-tax revenue invoice 16: Fully digitalized electronic invoice -1: Other By default, this parameter is left empty, which means to recognize all types of invoices. When a single type is passed in, the image is recognized based on this type. You can only specify a singe type or all types, but not some types. |
EnableOther | No | Boolean | Whether to enable recognition of other invoices. If you enable this feature, other invoices can be recognized. Default value: true . |
EnablePdf | No | Boolean | Whether to enable PDF recognition. If you enable this feature, both images and PDF files can be recognized. Default value: true . |
PdfPageNumber | No | Integer | The number of the PDF page that needs to be recognized. Only one single PDF page can be recognized. This parameter is valid if the uploaded file is a PDF and the value of EnablePdf is true . Default value: 1. |
EnableMultiplePage | No | Boolean | Whether to enable multi-page PDF recognition. If you enable this feature, multiple pages of a PDF file can be recognized, and the recognition results of a maximum of the first 30 pages can be returned. After you enable this feature, input parameters EnablePdf and PdfPageNumber are invalid. Default value: false . |
EnableCutImage | No | Boolean | Whether to return the Base64-encoded value of the cropped image. Default value: false . |
Parameter Name | Type | Description |
---|---|---|
MixedInvoiceItems | Array of InvoiceItem | Mixed invoice/ticket recognition result. Please click the link on the left for details. |
TotalPDFCount | Integer | Total number of pages in the PDF file. |
RequestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
This example shows you how to recognize a general invoice or ticket (advanced).
POST / HTTP/1.1
Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: RecognizeGeneralInvoice
<Common request parameters>
{
"ImageUrl": "abc",
"EnableMultiplePage": true
}
{
"Response": {
"MixedInvoiceItems": [
{
"Code": "OK",
"Type": 3,
"SubType": "VatSpecialInvoice",
"TypeDescription": "",
"SubTypeDescription": "",
"Polygon": {
"LeftBottom": {
"X": -18,
"Y": 880
},
"LeftTop": {
"X": -18,
"Y": 34
},
"RightBottom": {
"X": 1381,
"Y": 880
},
"RightTop": {
"X": 1381,
"Y": 34
}
},
"Angle": 270.2,
"SingleInvoiceInfos": {
"AirTransport": null,
"BusInvoice": null,
"MachinePrintedInvoice": null,
"MotorVehicleSaleInvoice": null,
"NonTaxIncomeElectronicBill": null,
"NonTaxIncomeGeneralBill": null,
"OtherInvoice": null,
"QuotaInvoice": null,
"ShippingInvoice": null,
"TaxiTicket": null,
"TollInvoice": null,
"TrainTicket": null,
"UsedCarPurchaseInvoice": null,
"VatCommonInvoice": null,
"VatElectronicCommonInvoice": null,
"VatElectronicInvoiceBlockchain": null,
"VatElectronicInvoiceFull": null,
"VatElectronicInvoiceToll": null,
"VatElectronicSpecialInvoice": null,
"VatElectronicSpecialInvoiceFull": null,
"VatInvoiceRoll": null,
"VatSpecialInvoice": {
"AgentMark": 0,
"Buyer": "",
"BuyerAddrTel": "",
"BuyerBankAccount": "",
"BuyerTaxID": "440300708461136",
"CheckCode": "",
"Ciphertext": "*7-0<84019---5+68315-99->/51,>814<1/7922/<-23/908+>7474+3,78312-072<3<729-+4<6*315-094,->/5>18493/1-60*6-43/90<--78",
"City": "",
"Code": "4403152130",
"CodeConfirm": "4403152130",
"CompanySealContent": "",
"CompanySealMark": 1,
"Date": "",
"FormType": "",
"Issuer": "",
"Kind": "",
"MachineCode": "",
"Number": "14998456",
"NumberConfirm": "14998456",
"OilMark": 0,
"PretaxAmount": "778.44",
"Province": "",
"QRCodeMark": 0,
"Receiptor": "",
"Remark": "",
"Reviewer": "",
"Seller": "",
"SellerAddrTel": "",
"SellerBankAccount": "",
"SellerTaxID": "440300094040109",
"ServiceName": "",
"Tax": "46.71",
"TaxSealContent": "",
"Title": "",
"Total": "825.15",
"TotalCn": "",
"TransitMark": 0,
"TravelTax": "",
"VatInvoiceItemInfos": [
{
"DateEnd": "",
"DateStart": "",
"LicensePlate": "",
"Name": "",
"Price": "",
"Quantity": "",
"Specification": "",
"Tax": "",
"TaxRate": "6%",
"Total": "778.44",
"Unit": "",
"VehicleType": ""
}
]
}
},
"Page": 1,
"CutImage": ""
},
{
"Code": "OK",
"Type": 13,
"SubType": "TollInvoice",
"TypeDescription": "",
"SubTypeDescription": "",
"Polygon": {
"LeftBottom": {
"X": 30,
"Y": 1478
},
"LeftTop": {
"X": 30,
"Y": 886
},
"RightBottom": {
"X": 496,
"Y": 1478
},
"RightTop": {
"X": 496,
"Y": 886
}
},
"Angle": 0.11452838033437729,
"SingleInvoiceInfos": {
"AirTransport": null,
"BusInvoice": null,
"MachinePrintedInvoice": null,
"MotorVehicleSaleInvoice": null,
"NonTaxIncomeElectronicBill": null,
"NonTaxIncomeGeneralBill": null,
"OtherInvoice": null,
"QuotaInvoice": null,
"ShippingInvoice": null,
"TaxiTicket": null,
"TollInvoice": {
"Code": "144031700221",
"Date": "",
"Entrance": "",
"Exit": "",
"HighwayMark": 1,
"Kind": "",
"Number": "27357827",
"QRCodeMark": 0,
"Time": "06:14:03",
"Title": "",
"Total": "5.00"
},
"TrainTicket": null,
"UsedCarPurchaseInvoice": null,
"VatCommonInvoice": null,
"VatElectronicCommonInvoice": null,
"VatElectronicInvoiceBlockchain": null,
"VatElectronicInvoiceFull": null,
"VatElectronicInvoiceToll": null,
"VatElectronicSpecialInvoice": null,
"VatElectronicSpecialInvoiceFull": null,
"VatInvoiceRoll": null,
"VatSpecialInvoice": null
},
"Page": 1,
"CutImage": ""
},
{
"Code": "OK",
"Type": 2,
"SubType": "TrainTicket",
"TypeDescription": "",
"SubTypeDescription": "",
"Polygon": {
"LeftBottom": {
"X": 517,
"Y": 1229
},
"LeftTop": {
"X": 517,
"Y": 950
},
"RightBottom": {
"X": 963,
"Y": 1229
},
"RightTop": {
"X": 963,
"Y": 950
}
},
"Angle": 0.04854407534003258,
"SingleInvoiceInfos": {
"AirTransport": null,
"BusInvoice": null,
"MachinePrintedInvoice": null,
"MotorVehicleSaleInvoice": null,
"NonTaxIncomeElectronicBill": null,
"NonTaxIncomeGeneralBill": null,
"OtherInvoice": null,
"QuotaInvoice": null,
"ShippingInvoice": null,
"TaxiTicket": null,
"TollInvoice": null,
"TrainTicket": {
"AdditionalFare": "",
"DateGetOn": "",
"GateNumber": "",
"HandlingFee": "",
"Kind": "",
"Name": "",
"Number": "Z96X089517",
"OriginalFare": "",
"PickUpAddress": "",
"QRCodeMark": 0,
"ReceiptNumber": "",
"ReimburseOnlyMark": 0,
"Seat": "",
"SeatNumber": "",
"SerialNumber": "30671300960307X089517",
"StationGetOff": "",
"StationGetOn": "",
"TicketChange": "0",
"TimeGetOn": "18:51",
"Title": "",
"Total": "46.50",
"TotalCn": "",
"TrainNumber": "Z196",
"UserID": "3210231991****6666"
},
"UsedCarPurchaseInvoice": null,
"VatCommonInvoice": null,
"VatElectronicCommonInvoice": null,
"VatElectronicInvoiceBlockchain": null,
"VatElectronicInvoiceFull": null,
"VatElectronicInvoiceToll": null,
"VatElectronicSpecialInvoice": null,
"VatElectronicSpecialInvoiceFull": null,
"VatInvoiceRoll": null,
"VatSpecialInvoice": null
},
"Page": 1,
"CutImage": ""
}
],
"RequestId": "a3a63bf5-a8b1-4563-b4d3-31c9a1c609b9",
"TotalPDFCount": 1
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
FailedOperation.DownLoadError | File download failed. |
FailedOperation.ImageBlur | The image is blurry. |
FailedOperation.ImageDecodeFailed | Image decoding failed. |
FailedOperation.OcrFailed | OCR failed. |
FailedOperation.UnKnowError | Unknown error. |
FailedOperation.UnOpenError | The service is not activated. |
InvalidParameterValue.InvalidParameterValueLimit | Incorrect parameter value. |
LimitExceeded.TooLargeFileError | The file is too large. |
ResourcesSoldOut.ChargeStatusException | Exceptional billing status. |
Was this page helpful?