跳至主要内容

文件識別

POST https://api.docai.pro/api/identify/file/v2/identify

概觀

通用識別接口,請基於模型ID發起模型調用。 您可以通過參數“synchronized”指定是同步還是非同步返回識別結果。

請求主體

名稱類型是否必填描述
modelId字串模型的唯一識別字
file文件需要識別的文件
legalPageNumbers字串要識別的頁碼,如果未指定,則會識別整個檔案。
workspaceCode字串模型內的工作空間名稱,如果為空,則默認使用"Default Workspace"。
isAsynchronous字串是否異步回傳識別結果,預設值: 0。1: 異步回傳,0: 同步回傳

legalPageNumbers示例:

1-1: 只需要識別第一頁;

2-3: 只需要識別第二頁和第三頁;

1-1, 3-4: 只需要識別第一頁、第三頁和第四頁.

響應主體

名稱類型是否必填描述
fileId字串上傳文件的唯一標識
recognizeStatus 字串 上傳文件識別狀態,0 失敗 1 成功 2 識別中
result對象識別字段

結果消息格式

名稱類型是否必填描述
fieldList對象數組 從檔案中選取的欄位清單
   pageNumber整數檔案中所在的頁數
   key字串選取欄位的欄位名
   value字串選取欄位的欄位名值
itemList對象數組檔案中提前的明細行資訊
   pageNumber整數檔案中所在的頁數
   key字串明細行的欄位名
   value字串明細行的欄位值

示例請求

curl -i -X POST https://api.docai.pro/api/identify/file/v2/identify \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $DOCAI_API_KEY" \
-F 'modelId=@MODEL_ID' \
-F 'file=@REPLACE_IMAGE_PATH.jpg'

同步示例響應

{
"code": 200,
"message": null,
"costTime": null,
"data": {
"fileId": "2310091711378393918074800",
"recognizeStatus": "1",
"result": {
"fieldList": [
{
"pageNumber": 1,
"key": "paymentTerms",
"value": "Payment is due within 15 days"
},
{
"pageNumber": 1,
"key": "invoiceDate",
"value": "2019-02-11"
},
{
"pageNumber": 1,
"key": "documentType",
"value": "invoice"
},
{
"pageNumber": 1,
"key": "invoiceNumber",
"value": "US-001"
},
{
"pageNumber": 1,
"key": "grossAmount",
"value": "154.06"
},
{
"pageNumber": 1,
"key": "totalTax",
"value": "9.06"
},
{
"pageNumber": 1,
"key": "dueDate",
"value": "2019-02-26"
}
],
"taxList": [
[
{
"pageNumber": 1,
"key": "taxValue",
"value": "9.06"
},
{
"pageNumber": 1,
"key": "taxPercentage",
"value": "6.25"
}
]
],
"itemList": [
[
{
"pageNumber": 1,
"key": "totalPriceInclTax",
"value": "100.00"
},
{
"pageNumber": 1,
"key": "unitPrice",
"value": "100.00"
},
{
"pageNumber": 1,
"key": "quantity",
"value": "1"
},
{
"pageNumber": 1,
"key": "description",
"value": "Front and rear brake cables"
},
{
"pageNumber": 1,
"key": "totalPriceExclTax",
"value": "100.00"
}
],
[
{
"pageNumber": 1,
"key": "totalPriceInclTax",
"value": "30.00"
},
{
"pageNumber": 1,
"key": "unitPrice",
"value": "15.00"
},
{
"pageNumber": 1,
"key": "quantity",
"value": "2"
},
{
"pageNumber": 1,
"key": "description",
"value": "New set of pedal arms"
},
{
"pageNumber": 1,
"key": "totalPriceExclTax",
"value": "30.00"
}
],
[
{
"pageNumber": 1,
"key": "totalPriceInclTax",
"value": "15.00"
},
{
"pageNumber": 1,
"key": "unitPrice",
"value": "5.00"
},
{
"pageNumber": 1,
"key": "quantity",
"value": "3"
},
{
"pageNumber": 1,
"key": "description",
"value": "Labor 3hrs"
},
{
"pageNumber": 1,
"key": "totalPriceExclTax",
"value": "15.00"
}
]
]
}
},
"requestId": "da69edd3cb1d47b4a68db9303d280000",
"currentTimeMillis": 1696859401185
}

異步示例響應

{
"code": 200,
"message": null,
"costTime": null,
"data": {
"fileId": "2310091711378393918074800",
"recognizeStatus": "1"
},
"requestId": "da69edd3cb1d47b4a68db9303d280000",
"currentTimeMillis": 1696859401185
}