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

siftrics-hydra-api

v1.1.0

Published

Official client for Siftrics' Hydra API, which is a text recognition documents-to-database service

Downloads

6

Readme

This repository contains the official Hydra API Node.js client. The Hydra API is a text recognition service.

Quickstart

  1. Install the node module.
npm install siftrics-hydra-api
  1. Create a new data source on siftrics.com.
  2. Grab an API key from the page of your newly created data source.
  3. Create a client, passing your API key into the constructor.
  4. Use the client to processes documents, passing in the id of a data source and the filepaths of the documents.
const hydra = require('siftrics-hydra-api');

const h = new hydra.Client('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');

h.recognize('my-data-source-id', ['invoice_1.pdf', 'my_receipt.png'])
    .then(rows => {
        console.log(rows);
    })
    .catch(error => {
        console.error(error);
    });

rows looks like this:

[
  {
    "Error": "",
    "FileIndex": 0,
    "RecognizedText": { ... }
  },
  ...
]

FileIndex is the index of this file in the original request's "files" array.

RecognizedText is an object mapping labels to values. Labels are the titles of the bounding boxes drawn during the creation of the data source. Values are the recognized text inside those bounding boxes.

Faster Results

The recognize function has a default parameter, config, which allows users to set various flags:

recognize(dataSourceId, files, config = {
    doFaster: false,
    returnTransformedImages: false,
    returnJpgs: false,
    jpgQuality: 85
})

If doFaster is set to true, then Siftrics processes the documents in half the time at the risk of lower text recognition accuracy. Experimentally, setting doFaster to true seems not to affect accuracy when all the documents to be processed have been rotated no more than 45 degrees.

Return Transformed / Pre-Processed Images

Hydra can transform input documents so they are cropped and aligned with the original image used to create the data source.

To enable this feature, set returnTransformedImages to true in config (see the "Faster Results" section above for an example of using config).

Returned images will be available in the "TransformedImages" field of each element of "Rows" in the response:

{
  "Rows": [
    {
      "Error": "",
      "FileIndex": 0,
      "RecognizedText": {
        "My Field 1": "text from your document...",
        "My Field 2": "text from your document...",
        ...
      },
      "TransformedImages": [
        {
          "Base64Image": ...,
          "PageNumber": 1
        },
        ...
      ]
    },
    ...
  ]
}

Export JPEGs instead of PNGs

If your data source returns cropped images, they are returned as PNGs encoded as base-64 strings. It is possible to return these images as JPEGs instead of PNGs, by setting returnJpgs to true in config (see the "Faster Results" section above for an example of using config). Additionally, there is a flag jpgQuality which is a number between 1 and 100 inclusive, which determines the quality of the encoded JPEGs. The default is 85. The higher the number, the higher the quality.

Returning JPEGs instead of PNGs with jpgQuality=85 typically exhibits a 7-10x reduction in image size, with minimal reduction in quality.

Official API Documentation

Here is the official documentation for the Hydra API.

Apache V2 License

This code is licensed under Apache V2.0. The full text of the license can be found in the "LICENSE" file.