飞机行程单识别
调试
您可以在API Explorer中调试该接口。
URI
POST https://{endpoint}/v2/{project_id}/ocr/flight-itinerary
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 Token认证就是在调用API的时候将Token加到请求消息头,从而通过身份认证,获得操作API的权限,响应消息头中X-Subject-Token的值即为Token。 |
参数 |
是否必选 |
参数类型 |
说明 |
---|---|---|---|
image |
否,该参数与url二选一 |
String |
图像数据,base64编码,要求base64编码后大小不超过10MB。 图片最小边不小于15px,最长边不超过8192px,支持JPEG、JPG、PNG、BMP、TIFF格式。 |
url |
否,该参数与image二选一 |
String |
图片的url路径,目前支持:
说明:
|
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
result |
调用成功时表示调用结果。 调用失败时无此字段。 |
参数 |
参数类型 |
描述 |
---|---|---|
serial_number |
String |
印刷序号。 |
passenger_name |
String |
旅客姓名。 |
id_number |
String |
有效身份证件号码。 |
endorsements_restrictions |
String |
备注。 |
order_number |
String |
订单号。 |
fare |
String |
票价。 |
caac_development_fund |
String |
民航(CAAC)发展基金。 |
fuel_surcharge |
String |
燃油附加费。 |
other_taxes |
String |
其他税费。 |
total |
String |
合计。 |
e_ticket_number |
String |
电子客票号码。 |
check_code |
String |
验证码。 |
reference_information |
String |
提示信息。 |
insurance |
String |
保险费。 |
agent_code |
String |
销售单位代号。 |
issue_organization |
String |
填开单位。 |
issue_date |
String |
填开日期。 |
itinerary_list |
Array of ItineraryList objects |
机票行程列表。 |
confidence |
Object |
相关字段的置信度信息,取值范围0~1。 置信度越大,表示本次识别的对应字段的可靠性越高,在统计意义上,置信度越大,准确率越高。 置信度由算法给出,不直接等价于对应字段的准确率。 |
参数 |
参数类型 |
描述 |
---|---|---|
departure_station |
String |
始发站。 |
destination_station |
String |
目的站。 |
carrier |
String |
承运人。 |
flight |
String |
航班号。 |
cabin_class |
String |
座位等级。 |
date |
String |
日期。 |
time |
String |
时间。 |
fare_basis |
String |
客票类别。 |
effective_date |
String |
客票生效日期。 |
expiry_date |
String |
有效截止日期。 |
baggage_allowance |
String |
免费行李。 |
状态码: 400
参数 |
参数类型 |
说明 |
---|---|---|
error_code |
String |
调用失败时的错误码,具体请参见错误码。 当出现错误码“ModelArts.4204”时,请参考为什么调用API时提示“ModelArts.4204”?章节。 调用成功时无此字段。 |
error_msg |
String |
调用失败时的错误信息。 调用成功时无此字段。 |
请求示例

- 请求示例(方式一:使用图片的base64编码)
POST https://{endpoint}/v2/{project_id}/ocr/flight-itinerary Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "image":"/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAA..." }
- 请求示例(方式二:使用图片URL)
POST https://{endpoint}/v2/{project_id}/ocr/flight-itinerary Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "url":"https://BucketName.obs.xxxx.com/ObjectName" }
- Python语言请求代码示例(其他语言参照下列示例编写或使用OCR SDK)
# encoding:utf-8 import requests import base64 url = "https://{endpoint}/v2/{project_id}/ocr/flight-itinerary" token = "用户获取得到的实际token值" headers = {'Content-Type': 'application/json', 'X-Auth-Token': token} imagepath = r'./data/flight-itinerary-demo.png' with open(imagepath, "rb") as bin_data: image_data = bin_data.read() image_base64 = base64.b64encode(image_data).decode("utf-8") # 使用图片的base64编码 payload = {"image": image_base64} # url与image参数二选一 response = requests.post(url, headers=headers, json=payload) print(response.text)
响应示例
状态码:200
成功响应示例
{ "result": { "serial_number": "12XXXXXXX22", "passenger_name": "WANG/SAN", "id_number": "GXXXXXX08", "endorsements_restrictions": "Q/不得签转/退改收费", "fare": "CNY 2340.00", "caac_development_fund": "CN 100.00", "fuel_surcharge": "XXXX", "other_taxes": "", "total": "CNY 2440.00", "e_ticket_number": "73XXXXXXXX008", "check_code": "3XXX", "reference_information": "白云机场起飞前45分停办值机", "insurance": "XXX", "agent_code": "SXXXXX 00XXXX66", "issue_organization": "XX航空股份有限公司", "issue_date": "2017-12-27", "itinerary_list": [ { "departure_station": "T2上海虹桥", "destination_station": "广州", "carrier": "X航", "flight": "XXXXXX", "cabin_class": "B", "date": "2017-12-27", "time": "13:00", "fare_basis": "B", "effective_date": "", "expiry_date": "", "baggage_allowance": "20K" }, { "departure_station": "广州", "destination_station": "上海虹桥", "carrier": "XXXX", "flight": "XXXXXX", "cabin_class": "B", "date": "2017-12-29", "time": "16:30", "fare_basis": "B", "effective_date": "", "expiry_date": "", "baggage_allowance": "20K" } ], "confidence":{ "serial_number": 0.9993, "passenger_name": 0.9851, "id_number": 0.9836, "endorsements_restrictions": 0.998, "fare": 0.9882, "caac_development_fund": 0.993, "fuel_surcharge": 0.9968, "other_taxes": 0, "total": 0.9999, "e_ticket_number": 0.9631, "check_code": 0.9985, "reference_information": 1.0, "insurance": 0.7749, "agent_code": 0.9913, "issue_organization": 0.7142, "issue_date": 0.9936, "itinerary_list": [ { "departure_station": 1.0, "destination_station": 0.9577, "carrier": 0.9677, "flight": 0.9957, "cabin_class": 0.8744, "date": 0.9993, "time": 0.9978, "fare_basis": 0.4006, "effective_date": 0, "expiry_date": 0, "baggage_allowance": 0.9897 }, { "departure_station": 1.0, "destination_station": 0.9844, "carrier": 0.9763, "flight": 0.7453, "cabin_class": 0.4239, "date": 0.76, "time": 0.7311, "fare_basis": 0.4353, "effective_date": 0, "expiry_date": 0, "baggage_allowance": 0.5265 } ] } } }
状态码:400
失败响应示例
{ "error_code": "AIS.0103", "error_msg": "The image size does not meet the requirements." }
错误码
错误码请参见错误码。
