# @affinda/affinda 中文文档

规范地址：https://npmcn.com/package/%40affinda/affinda/

版本：7\.7\.1
npm 元数据更新时间：2026-04-04T23:34:16.132Z
中文译文更新时间：2026-11-06T01:56:05.623Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40affinda/affinda
原文对照：https://npmcn.com/package/%40affinda/affinda/?lang=original
项目主页：https://github.com/affinda/affinda-typescript
源码仓库：https://github.com/affinda/affinda-typescript

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：4.7 MB，48 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=12\.0\.0
- 运行依赖：8 个
- 首次发布：2021-08-25T05:51:49.928Z
- 最新版本发布：2025-12-10T04:45:26.582Z
- 近 30 天下载量：6901（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：106（近 12 个月 1 个）

## 中文简介

AffindaAPI 的客户端

## 安装

```sh
npm install @affinda/affinda
```

也可以使用：`pnpm add @affinda/affinda`、`yarn add @affinda/affinda`、`bun add @affinda/affinda`

## README

# Affinda Resume Parser API 的打字客户端库

![affinda logo](https://api.affinda.com/static/documentation/affinda_logo.png) [![license](https://img.shields.io/github/license/affinda/affinda-typescript)](https://choosealicense.com/licenses/mit/)

[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/affinda/affinda-typescript)

-   [安装](https://npmcn.com/package/%40affinda/affinda/#readme-installation)
-   [快速启动](https://npmcn.com/package/%40affinda/affinda/#readme-quickstart)
-   [API 参考](https://npmcn.com/package/%40affinda/affinda/#readme-api-reference)
-   [样本](https://npmcn.com/package/%40affinda/affinda/#readme-samples)
-   [解决问题](https://npmcn.com/package/%40affinda/affinda/#readme-troubleshooting)

使用 [自动](https://github.com/Azure/autorest) 财务报告和审定财务报表 [自定义.typescript](https://github.com/Azure/autorest.typescript)。 。 。 .

[软件包( NPM)](https://www.npmjs.com/package/@affinda/affinda)

## 安装

```bash
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密钥. 跟着我们的步伐 [文档](https://docs.affinda.com/docs/getting-started-with-affinda)。 。 。 .

### 目前得到支持的环境

-   [节点.js的LTS版本](https://nodejs.org/about/releases/)
-   Safari,Chrome,Edge,和Firefox的最新版本.

### 安装 `affinda` 软件包

为 JavaScript 安装服务客户端库 `npm`数字 :

```bash
npm install @affinda/affinda
```

或从源建置:

```shell
git clone git@github.com:affinda/affinda-typescript.git
npm install
npm build
```

解析简历的实例 :

```javascript
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”文档类型生成打字符界面 :

```bash
# Assuming your Resume Parser document type ID is "rLERIsHk"
npm exec affinda-generate-interfaces -- --document-type-id=rLERIsHk
```

您的 API 密钥将被提示, 除非您已经拥有了 `AFFINDA_API_KEY` 环境变量集.

生成的打字符接口将会在 `./affinda-interfaces` 默认.

对于您可以使用的所有选项, 请运行 :

```bash
npm exec affinda-generate-interfaces -- --help
```

## API 参考

生成一个完整的 API 参考 [类型doc](https://github.com/TypeStrong/typedoc) 实值 [此处可用](https://npmcn.com/package/%40affinda/affinda/docs/globals.md)

## 解决问题

### 日志

允许伐木可能有助于发现有关失败的有用信息。 要查看 HTTP 请求的日志和 答复,设置 `AZURE_LOG_LEVEL` 环境变量改为 `info`或者,可以在运行时启用记录 电话 `setLogLevel` 输入 `@azure/logger`数字 :

```javascript
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
```

关于如何启用日志的更详细指示,您可以查看 页:1 [@ azure/ logger (缩写)](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/logger) 数据包.

## 常见问题

### @affinda/affinda 是什么？

AffindaAPI 的客户端

### 如何安装 @affinda/affinda？

在项目目录运行 npm install @affinda/affinda，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 affinda-generate-interfaces，可以用 npx affinda-generate-interfaces 直接运行。

### @affinda/affinda 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @affinda/affinda 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @affinda/affinda 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=12\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @affinda/affinda 可以商用吗？

@affinda/affinda 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @affinda/affinda 的下载量有多少？

根据 npm 官方下载统计，@affinda/affinda 在 2026/10/05 – 2026/11/03 这 30 天内被下载 6,901 次，日均约 230 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @affinda/affinda 还在维护吗？

最新版本 7\.7\.1 发布于 2025/12/10（10 个月前）；至今共发布 106 个版本，其中过去 12 个月发布了 1 个；首次发布于 2021/08/25。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

