npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mindee

v4.21.0

Published

Mindee Client Library for Node.js

Downloads

44,683

Readme

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