@affinda/affinda

中文文档
7.7.1发布于 2025/12/10MITTypeScriptESM + CJS近 30 天下载 6901

A client for the AffindaAPI

原始使用文档
文档目录9 节
  1. Installation
  2. API Version Compatibility
  3. Quickstart
  4. Currently supported environments
  5. Install the affinda package
  6. Typescript interfaces
  7. API reference
  8. Troubleshooting
  9. Logging

Typescript Client Library for Affinda Resume Parser API

affinda logo license

Open in Visual Studio Code

Generated using autorest and autorest.typescript.

Package (NPM)

Installation

npm install @affinda/affinda

API Version Compatibility

The Affinda API is currently on v3, with breaking changes meant the release of new versions of the client library. Please see below for which versions are compatible with which API version.

Affinda API versionaffinda-typescript versions
v20.1.0 - 5.x.x
v3>= 6.x.x

Quickstart

Before using the API, you need to create an account, setup a workspace, and obtain an API key. Follow the steps in our documentation.

Currently supported environments

Install the affinda package

Install the Service client library for JavaScript with npm:

npm install @affinda/affinda

or build from source:

git clone [email protected]:affinda/affinda-typescript.git
npm install
npm build

Example parsing a resume:

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));

Typescript interfaces

You can generate typescript interfaces to help with consuming the API response in a type-safe way.

Use the affinda-generate-interfaces command to auto-generate typescript interfaces from your document type configuration.

For example, this will generate typescript interfaces for your "Resume Parser" document type:

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

You will be prompted for your API key, unless you already have the AFFINDA_API_KEY environment variable set.

The generated typescript interfaces will be in ./affinda-interfaces by default.

For all the options you can use, run:

npm exec affinda-generate-interfaces -- --help

API reference

A full API reference generated with typedoc is available here

Troubleshooting

Logging

Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:

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

setLogLevel("info");

For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.

版本与发布记录

@affinda/affinda 共发布 106 个版本,首次发布于 2021/08/25;过去 12 个月发布了 1 个版本。

版本发布日期距今
7.7.1latest2025/12/1010 个月前
7.7.02025/09/241.1 年前
7.6.12025/07/021.3 年前
7.6.02025/07/021.3 年前
7.5.02025/05/081.5 年前
7.4.02024/10/012 年前

关于 @affinda/affinda 的常见问题

@affinda/affinda 是什么?

A client for the 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 和提交记录判断。