Affinda Resume Parser API 的打字客户端库
使用 自动 财务报告和审定财务报表 自定义.typescript。 。 。 .
安装
npm install @affinda/affinda
API 版本兼容性
Affinda API目前开通 v3,随着突破的更改意味着发布客户端库的新版本.
请见下文哪些版本与API版本兼容.
| Affinda API 版本 | affinda-typescript 版本 |
|---|---|
| 页:1 | 01.0 - 5.x.x |
| 页:1 | >= 6.x.x |
快速启动
在使用API之前,需要创建账户,设置工作空间,并获得API密钥. 跟着我们的步伐 文档。 。 。 .
目前得到支持的环境
- 节点.js的LTS版本
- Safari,Chrome,Edge,和Firefox的最新版本.
安装 affinda 软件包
为 JavaScript 安装服务客户端库 npm数字 :
npm install @affinda/affinda
或从源建置:
git clone [email protected]:affinda/affinda-typescript.git
npm install
npm build
解析简历的实例 :
import { AffindaAPI, AffindaCredential } from "@affinda/affinda";
import * as fs from "fs";
const credential = new AffindaCredential("YOUR_API_KEY");
const client = new AffindaAPI(credential);
const file = fs.createReadStream("resume.pdf");
client
.createDocument({
file,
workspace: "YOUR_WORKSPACE_IDENTIFIER",
})
.then(doc => {
console.log("Parsed data:", doc.data);
})
.catch(err => console.error("Error:", err));
字体界面
可以生成打字符接口来帮助以类型安全的方式消耗API响应.
使用 affinda-generate-interfaces 命令以自动生成文档类型配置中的打字符界面.
例如,这将为您的“Resume Parser”文档类型生成打字符界面 :
# Assuming your Resume Parser document type ID is "rLERIsHk"
npm exec affinda-generate-interfaces -- --document-type-id=rLERIsHk
您的 API 密钥将被提示, 除非您已经拥有了 AFFINDA_API_KEY 环境变量集.
生成的打字符接口将会在 ./affinda-interfaces 默认.
对于您可以使用的所有选项, 请运行 :
npm exec affinda-generate-interfaces -- --help
API 参考
解决问题
日志
允许伐木可能有助于发现有关失败的有用信息。 要查看 HTTP 请求的日志和
答复,设置 AZURE_LOG_LEVEL 环境变量改为 info或者,可以在运行时启用记录
电话 setLogLevel 输入 @azure/logger数字 :
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
关于如何启用日志的更详细指示,您可以查看 页:1 @ azure/ logger (缩写) 数据包.