@affinda/affinda
TypeScript icon, indicating that this package has built-in type declarations

7.6.1 • Public • Published

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 version affinda-typescript versions
v2 0.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 git@github.com: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.

Package Sidebar

Install

npm i @affinda/affinda

Weekly Downloads

1,957

Version

7.6.1

License

MIT

Unpacked Size

4.65 MB

Total Files

48

Last publish

Collaborators

  • affindabot
  • ralish
  • cfculhane