python的mindeeapi帮助程序库
mindee的Python项目详细描述
python的mindeeapi帮助程序库
完整的文档可用here
安装
使用pip从PyPi安装,pip是Python的包管理器。在
pip install mindee
没有安装pip吗?通过从命令行运行以下命令,尝试安装它:
^{pr2}$开始使用mindeeapi非常容易。创建一个客户,你就可以开始了。在
创建客户机
在mindee客户需要你的API凭据。您可以直接将它们传递给构造函数(请参阅下面的代码)或通过环境变量。在
根据要解析的文档类型,需要为每个端点添加特定的身份验证令牌。在
frommindeeimportClientmindee_client=Client(expense_receipts_token="your_expense_receipts_api_token_here",invoice_token="your_invoice_api_token_here",passport_token="your_passport_api_token_here",license_plate_token="your_license_plate_api_token_here",raise_on_error=True)
我们建议将凭据存储为环境变量。为什么?你不必担心提交你的证书,不小心把它们张贴在公共场所。在
解析方法
# Call the receipt parsing API and create a receipt object under parsed_data.receiptparsed_data=mindee_client.parse_receipt("/path/to/file")# Call the invoice parsing API and create an invoice object under parsed_data.invoiceparsed_data=mindee_client.parse_invoice("/path/to/file")# If you have a mixed data flow of invoice and receipt, use financial_document class# Call the invoice or receipt parsing API according to your input data type# and create a FinancialDocument object under parsed_data.financial_documentparsed_data=mindee_client.parse_financial_document("/path/to/file")# Call the passport parsing API and create a Passport object under parsed_data.passportparsed_data=mindee_client.parse_passport("/path/to/file")# Call the license_plates parsing API and create a CarPlate object under parsed_data.license_plateparsed_data=mindee_client.parse_license_plate("/path/to/file")
输入数据
可以通过三种方式传递输入文件:
从文件路径
receipt_data=mindee_client.parse_receipt('/path/to/file',input_type="path")
从文件对象
withopen('/path/to/file','rb')asfp:receipt_data=mindee_client.parse_receipt(fp,input_type="file")
从垒64开始
receipt_data=mindee_client.parse_receipt(base64_string,input_type="base64")
- 项目
标签: