同步文件base64識別
POST https://api.docai.pro/api/identify/file/v2/identifyByEncodeString
概觀
通用識別接口,請基於模型ID發起模型調用。 該接口將返回base64文件的識別結果。
請求主體
名稱 | 類型 | 是否必填 | 描述 |
---|---|---|---|
modelId | 字串 | 是 | 模型的唯一識別字 |
encodeString | 字串 | 是 | 需要識別文件的base64編碼 |
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/identifyByEncodeString \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $DOCAI_API_KEY" \
-F 'modelId=@MODEL_ID' \
-F 'encodeString=@FILE_BASE64_ENCODEING'
同步示例響應
{
"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
}