Quickly and easily connect to Mindee's API services using Node.js.
Here's the TL;DR of getting started.
First, get an API Key
Then, install this library:
npm install mindee
Finally, Node.js away!
const mindee = require("mindee");
// for TS or modules:
// import * as mindee from "mindee";
// Init a new client
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
// Load a file from disk
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
// Parse it on the API of your choice
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 use the following syntax:
const mindee = require("mindee");
// for TS or modules:
// import * as mindee from "mindee";
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
// The IdCardV1 product belongs to mindee.product.fr, not mindee.product itself
const apiResponse = mindeeClient.parse(mindee.product.fr.IdCardV1, inputSource);
Custom documents will require you to provide their endpoint manually.
const mindee = require("mindee");
// for TS or modules:
// import * as mindee from "mindee";
// Init a new client
const mindeeClient = new mindee.Client({
apiKey: "my-api-key"
});
// Load a file from disk
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
// Create a custom endpoint for your product
const customEndpoint = mindeeClient.createEndpoint(
"my-endpoint",
"my-account",
"my-version" // will default to 1 if not provided
);
// Parse it
const apiResponse = mindeeClient
.parse(
mindee.product.CustomV1,
inputSource,
{
endpoint: customEndpoint
}
);
// Handle the response Promise
apiResponse.then((resp) => {
// print a string summary
console.log(resp.document.toString());
// individual pages (array)
console.log(res.document.inference.pages);
});
Options to pass when sending a file to be parsed.
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
}
});
Complete details on the working of the library are available in the following guides:
- Node.js Getting Started
- Node.js Generated API
- Node.js Custom OCR (Deprecated)
- Node.js Invoice OCR
- Node.js International Id OCR
- Node.js Receipt OCR
- Node.js Resume OCR
- Node.js Financial Document OCR
- Node.js Passport OCR
- Node.js Proof of Address OCR
- Node.js EU License Plate OCR
- Node.js EU Driver License OCR
- Node.js FR Bank Account Detail OCR
- Node.js FR Carte Vitale OCR
- Node.js FR ID Card OCR
- Node.js US Bank Check OCR
- Node.js US W9 OCR
- Node.js US Driver License OCR
- Node.js Barcode Reader API
- Node.js Cropper API
- Node.js Invoice Splitter API
- Node.js Multi Receipts Detector API
You can also take a look at the Reference Documentation.
Copyright © Mindee
Available as open source under the terms of the MIT License.