Generated using autorest and autorest.typescript.
npm install @affinda/affinda
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 |
Before using the API, you need to create an account, setup a workspace, and obtain an API key. Follow the steps in our documentation.
- LTS versions of Node.js
- Latest versions of Safari, Chrome, Edge, and Firefox.
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));
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
A full API reference generated with typedoc is available here
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.