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

sbx-parse-api

v0.1.6

Published

JavaScript API for Securibox Parse

Downloads

1

Readme

Securibox Parse - JavaScript API

A Javascript API for Securibox Parse

Community

Securibox Parse JavaScript API is an open source software released under LGPL-3.0 license.

You are welcome to report bugs or create pull requests on github.

Installation

The easiest way to install sbx-parse-api is with npm.

npm install sbx-parse-api

Alternatively, download the source.

git clone https://github.com/Securibox/parse-api-js.git

Usage

Creating a parser

import {Parse, AuthMethods} from "sbx-parse-api";

// Using JWT authentication
let jwt = "thisIsMyEncodedToken";
authMethod = AuthMethods.JWT;
var parser = new Parse(url, authMethod, jwt);

// OR, with basic authentication:
// user = "MyUsername";
// password = "MySecretPassword";
// authMethod = AuthMethods.BASIC;
// var parser = new Parse(url, authMethod, user, password);

Authentication

Supported authentication methods:

API Methods

After you have instanciated a Parse object, you can use it to call the API. Every call will return a Promise. Only requests returning a 200 HTTP code will result in a fulfilled promise and trigger the .then() method; everything else will fall into the .catch() method and return an error structured as {"error": [Error Object]}.

The API has four methods:

  • classify(docs, take=5): takes a set of documents and labels them. Internally, the classification is done in two steps: first a fast algorithm returns a list of candidate labels; then a slower high-precision algorithm choses among the take most probable labels and determines the document's specific layout. The take optional parameter is a number between 1 and 9 (5 is the default value).
  • parse(docs, take=5, mode=undefined): takes a set of documents, classifies and parses them. Along with the take parameter (same as in classify), it accepts an optional mode parameter, that can be one of the following:
    • undefined (default) - handles every document as it is
    • "split" - splits the document into pages and handles every page as a separate document.
  • guess(docs): takes a set of partially parsed documents with similar layout and tries to infere the missing data. This method can be used to speed up data entry when the parse method fails.
  • feed(docs): takes a set of documents and stores them for the next training cycles. This method must be used with wrongly classified or wrongly parsed documents after the errors have been corrected by the user; it allows the application to learn and improve over time.

Objects

The docs object is used on both Requests and Responses. The structure is always an array of the following dictionary:

  • id: the document identifier, must be unique in the set
  • buffer or bytes or content: the content of the PDF document. The buffer is waiting for an ArrayBuffer, the bytes is waiting for an array of bytes while the content is the content of the PDF in base64 encoding. Only exists on Requests.
  • labelId (optional): the document label identifier
    • parse() and classify(): if filled, the document will be only layout-classified
    • feed(): used to train the models
    • Response: will be filled with the best matching label
  • detailedLabelId (optional): the document layout identifier
    • parse() and classify(): if filled, the document will not be classified
    • Response: will be filled with the best matching layout
  • extractedData: the extracted data fields. Array object, every item contains a name and a value field. Returned on parse() and guess(), should be filled on feed() and (for some documents) on guess().
  • errors: an array containing processing errors for the specific document. Storing errors by document allows you to successfully process the rest of the batch.

Sample

let docs = [];
let doc = {id: "Doc_01", content: "Base64ContentMustGoHere"};
docs.push(doc);
parser.parse(docs).then(function(parsedDocs){
    // parsedDocs is an array of documents
    alert("The doc contains " + parsedDocs[0].extractedData);
});