4.23.1 • Published 3 months ago

mindee v4.23.1

Weekly downloads
12
License
MIT
Repository
github
Last release
3 months ago

License: MIT GitHub Workflow Status NPM Version Downloads

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");
// 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 base64 encoded string:

const inputSource = mindeeClient.docFromBase64(myInputString, "my-file-name.ext")

A byte sequence:

const inputSource = mindeeClient.docFromBytes(myInputBytes, "my-file-name.ext")

A stream:

const inputSource = mindeeClient.docFromStream(myReadableStream, "my-file-name.ext")

A buffer:

const inputSource = mindeeClient.docFromBuffer(myBuffer, "my-file-name.ext")

A URL (https only):

const inputSource = mindeeClient.docFromUrl("https://my-url");

You can also load the document locally before sending it:

const inputSource = mindeeClient.docFromUrl("https://my-url");
await inputSource.init();
const localInputSource = inputSource.asLocalInputSource();

Note: Files hidden behind redirections are rejected by the server; this solution helps to circumvent that issue.

Region-Specific Documents

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 (docTI & Custom APIs)

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 = await mindeeClient
  .enqueueAndParse(
    mindee.product.GeneratedV1,
    inputSource,
    {
      endpoint: customEndpoint
    }
  );

Handling the Return

// 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);
});

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

4.18.1

7 months ago

4.18.0

7 months ago

4.23.0

4 months ago

4.23.1

3 months ago

4.21.0

6 months ago

4.19.0

6 months ago

4.22.0

5 months ago

4.20.0

6 months ago

4.14.1

9 months ago

4.16.0

9 months ago

4.15.0

9 months ago

4.17.0

8 months ago

4.17.1

8 months ago

4.12.0

1 year ago

4.14.0

11 months ago

4.13.0

1 year ago

4.13.1

12 months ago

4.11.0

1 year ago

4.10.0

1 year ago

4.9.1

1 year ago

4.9.0

1 year ago

4.8.2

1 year ago

4.8.1

1 year ago

4.8.0

1 year ago

4.7.0

1 year ago

4.6.1

1 year ago

4.6.0

1 year ago

4.5.0

2 years ago

4.4.0

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.3.3

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

4.1.0

2 years ago

4.1.1

2 years ago

3.9.0

2 years ago

3.10.1

2 years ago

3.8.0

2 years ago

3.10.0

2 years ago

3.10.2

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.2

2 years ago

3.7.4

2 years ago

3.7.3

2 years ago

3.7.2

2 years ago

3.7.1

2 years ago

3.7.0

2 years ago

3.6.0

2 years ago

3.5.0

2 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

3.4.0

2 years ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.4.1

2 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-rc1

5 years ago