@affinda/affinda
v7.7.1
Published
A client for the AffindaAPI
Downloads
9,674
Readme
Typescript Client Library for Affinda Resume Parser API
Generated using autorest and autorest.typescript.
Installation
npm install @affinda/affindaAPI 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
- LTS versions of Node.js
- Latest versions of Safari, Chrome, Edge, and Firefox.
Install the affinda package
Install the Service client library for JavaScript with npm:
npm install @affinda/affindaor build from source:
git clone [email protected]:affinda/affinda-typescript.git
npm install
npm buildExample 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=rLERIsHkYou 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 -- --helpAPI 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.
