Mindee API Helper Library for Node.js
Quickly and easily connect to Mindee's API services using Node.js.
Quick Start
Here's the TL;DR of getting started.
First, get an API Key
Then, install this library:
npm install mindee
Finally, Node.js away!
Loading a File and Parsing It
Global Documents
const mindee = require("mindee");
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
const apiResponse = mindeeClient.parse(mindee.product.InvoiceV4, inputSource);
Note: Files can also be loaded from:
A URL (https
only):
const inputSource = mindeeClient.docFromUrl("https://my-url");
A base64 encoded string:
const inputSource = mindeeClient.docFromBase64(myInputString, "my-file-name")
A stream:
const inputSource = mindeeClient.docFromStream(myReadableStream, "my-file-name")
A buffer:
const inputSource = mindeeClient.docFromBuffer(myBuffer, "my-file-name")
Region-Specific Documents
Region-Specific Documents use the following syntax:
const mindee = require("mindee");
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
const apiResponse = mindeeClient.parse(mindee.product.fr.IdCardV1, inputSource);
Custom Documents (API Builder)
Custom documents will require you to provide their endpoint manually.
const mindee = require("mindee");
const mindeeClient = new mindee.Client({
apiKey: "my-api-key"
});
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
const customEndpoint = mindeeClient.createEndpoint(
"my-endpoint",
"my-account",
"my-version"
);
const apiResponse = mindeeClient
.parse(
mindee.product.CustomV1,
inputSource,
{
endpoint: customEndpoint
}
);
Handling the Return
apiResponse.then((resp) => {
console.log(resp.document.toString());
console.log(res.document.inference.pages);
});
Additional Options
Options to pass when sending a file to be parsed.
Page Options
Allows only sending certain pages in a PDF.
In this example we only send the first, penultimate, and last pages:
const apiResponse = mindeeClient.parse(
mindee.product.InvoiceV4,
inputSource,
{
pageOptions: {
pageIndexes: [0, -2, -1],
operation: mindee.PageOptionsOperation.KeepOnly,
onMinPages: 2
}
});
Further Reading
Complete details on the working of the library are available in the following guides:
You can also take a look at the Reference Documentation.
License
Copyright © Mindee
Available as open source under the terms of the MIT License.
Questions?
Join our Slack