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

parble

v1.2.7

Published

Parble Javascript SDK

Downloads

17

Readme

Parble Javascript SDK

Package build

Official Node.js SDK for Parble intelligent document processing API.

To access the API you will need a Parble account. Sign up for free at signup.

If you would like to check the extended documentation please check this link.

Installation

With NPM

npm install parble

Constructor

The SDK requires 2 settings to connect and authenticate to the Parble API, which can be found in your Parble dashboard:

  • The name of your tenant
  • Your personal API-Key

In most cases you will need to require the Parble module:

const parble = require('parble');

However if you're building your own module, or using TypeScript, the equivalent would be:

import * as parble from 'parble';

With either of the possibilities the next step is to initialize the Parble client with your settings, both passed as strings:

const parble_sdk = new parble.parbleSDK('your_tenant', 'your_api_key');

Main usage examples

Get predictions from a file upload

After initializing the client, to process a file you need to call the files.post method by, either indicating the file local or temp path, or using a base64 string as an argument. The inbox_id where the file needs to be sent is also passed as a second argument. After processing is over you can see the results by either chaining to the promise or by async/await.

With local or temp* file path using chaining

parble_sdk.files
  .post('/path/to/your/file', 'your_inbox_id')
  .then((file_results: PredictedFileOutput) => {
    console.log(file_results);
  });

// Expect a JSON with: id, filename, timings, automated, number_of_pages and documents

*if you are already posting formdata to your node.js application we recommend using 'IncomingForm' from 'formidable' to read the tempfile and use the temp path as an argument.

With a base64 string and using async/await

async function process_file() {
  const file_results = await parble_sdk.files.post(
    'data:@file/pdf;base64,JVBERi0c...',
    'your_inbox_id'
  );
  console.log(file_results);
}

// Expect a JSON with: id, filename, timings, automated, number_of_pages and documents

Extra features

We will show here the async/await forms but all can be used by promise chaining also as shown above.

Check json from a file id

To check json from a previously processed file you need to call the files.get method using the file id as argument.

async function get_file_results(file_id: string) {
  const file_results = await parble_sdk.files.get(file_id);
  console.log(file_results);
}

// Expect a JSON with: id, filename, timings, automated, number_of_pages and documents

Check your tenant usage stats

To check your tenant usage stats during certain period you may use the following function and providing start and end dates as parameters. Mind that dates are passed as datetime strings, i.ex.: "2023-05-15" or the full "2023-05-15T09:11:51.043170".

async function get_usage(start_date: string, end_date: string) {
  const usage_stats = await parble_sdk.stats.usage(start_date, end_date);
  console.log(usage_stats);
}

// Expect a JSON with the counts of: files, documents and pages

In a similar way you can access to the tenant automation rates with the automation functionality under stats.

Manage your API keys

Ability to create new API keys for different integrations. API keys are all equal so no parameters are required to create more.

async function create_key() {
  const new_api_key = await parble_sdk.apikeys.createOne();
  console.log(new_api_key);
}

// Expect a JSON with: id, active, expiry_at and token

Around this API keys functionality you can also getAll to access the list of all the available API keys, getOne to see the data of a concrete API key or even deleteOne to remove certain API key.

Check balance of the account

There is the possibility of checking the balance of the account. This functionality provides info about the current balance, the total credit and the total used credit.

async function check_balance() {
  const balance = await parble_sdk.accounting.balance();
  console.log(balance);
}

// Expect a JSON with the money counts of: balance, credit and usage

License

The Parble Javascript SDK is released under the MIT License.