Socket
Socket
Sign inDemoInstall

sensible-api

Package Overview
Dependencies
29
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

2

dist/index.js

@@ -75,3 +75,3 @@ "use strict";

: "") +
"?".concat(querystring.stringify(__assign(__assign({}, (environment ? { environment: environment } : {})), (documentName ? { documentName: documentName } : {}))));
"?".concat(querystring.stringify(__assign(__assign({}, (environment ? { environment: environment } : {})), (documentName ? { document_name: documentName } : {}))));
body = __assign(__assign(__assign({}, ("url" in params ? { document_url: params.url } : {})), (webhook ? { webhook: webhook } : {})), ("documentTypes" in params ? { types: params.documentTypes } : {}));

@@ -78,0 +78,0 @@ headers = { authorization: "Bearer ".concat(this.apiKey) };

{
"name": "sensible-api",
"version": "0.0.7",
"version": "0.0.8",
"description": "Javascript SDK for Sensible, the developer-first platform for extracting structured data from documents so that you can build document-automation features into your SaaS products",

@@ -5,0 +5,0 @@ "keywords": ["IDP","parsing","conversion","openai","processing","csv","excel","convert","json","LLMs","pdf","png","tiff","jpeg","doc","docx","document","text","data","extraction","extract","classification","classify","sensible","openapi","gpt-3","gpt-4","senseml","automation","sdk","query","document-processing"," intelligent-document-processing"," pdf-conversion"," pdf-extraction"," document-extraction"," pdf-crawler","pdf-parser","pdf-extract","pdf-to-data","document-data-extraction","document-automation","sensible-api"],

@@ -30,12 +30,15 @@

In an environment in which you've installed Node, create a directory for a test project, open a command prompt in the directory, and install the dependencies:
In an environment with Node installed, open a command prompt and enter the following commands to create a test project:
```shell
npm install sensible-api
mkdir sensible-test
cd sensible-test
touch index.mjs
```
To import Sensible to your project, create an `index.mjs` file in your test project, and add the following lines to the file:
Then install the SDK:
```node
import { SensibleSDK } from "sensible-api";
```shell
npm install sensible-api
```

@@ -135,3 +138,4 @@

configurationName: "1040_2021",
"environment": "development",
environment: "development",
documentName="1040_john_doe.pdf",
webhook: {

@@ -147,3 +151,3 @@ url:"YOUR_WEBHOOK_URL",

| ----------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| path | string | The path to the document you want to extract from. For more information about supported file types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| path | string | The path to the document you want to extract from. For more information about supported file size and types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| file | string | The non-encoded bytes of the document you want to extract from. |

@@ -153,6 +157,6 @@ | url | string | The URL of the document you want to extract from. URL must:<br/>- respond to a GET request with the bytes of the document you want to extract data from <br/>- be either publicly accessible, or presigned with a security token as part of the URL path.<br/>To check if the URL meets these criteria, open the URL with a web browser. The browser must either render the document as a full-page view with no other data, or download the document, without prompting for authentication. |

| documentTypes | array | Types of documents to extract from. Use this parameter to extract from multiple documents that are packaged into one file (a "portfolio"). This parameter specifies the document types contained in the portfolio. Sensible then segments the portfolio into documents using the specified document types (for example, 1099, w2, and bank_statement) and then runs extractions for each document. For more information, see [Multi-doc extraction](https://docs.sensible.so/docs/portfolio). |
| configurationName | string | If specified, Sensible uses the specified config to extract data from the document instead of automatically choosing the configuration.<br/>If unspecified, Sensible automatically chooses the best-scoring extraction from the configs in the document type.<br/>Not applicable for portfolios. |
| configurationName | string | Sensible uses the specified config to extract data from the document instead of automatically choosing the configuration.<br/>If unspecified, Sensible chooses the best-scoring extraction from the configs in the document type.<br/>Not applicable for portfolios. |
| documentName | string | If you specify the file name of the document using this parameter, then Sensible returns the file name in the extraction response and populates the file name in the Sensible app's list of recent extractions. |
| environment | `"production"` or `"development"`. default: `"production"` | If you specify `development`, Sensible extracts preferentially using config versions published to the development environment in the Sensible app. The extraction runs all configs in the doc type before picking the best fit. For each config, falls back to production version if no development version of the config exists. |
| webhook | object | Specifies to return extraction results to the specified webhook URL as soon as they're complete, so you don't have to poll for results status. Sensible also calls this webhook on error.<br/> The webhook object has the following parameters:<br/>`url`: string. Webhook destination. Sensible will POST to this URL when the extraction is complete.<br/>`payload`: string, number, boolean, object, or array. Information additional to the API response, for example a UUID for verification. |
| webhook | object | Specifies to return extraction results to the specified webhook URL as soon as they're complete, so you don't have to poll for results status. Sensible also calls this webhook on error.<br/> The webhook object has the following parameters:<br/>`url`: string. Webhook destination. Sensible posts to this URL when the extraction is complete.<br/>`payload`: string, number, boolean, object, or array. Information additional to the API response, for example a UUID for verification. |

@@ -163,7 +167,7 @@ ### Extraction results

For the schema for the results of an extraction request, see [Extract data from a document](https://docs.sensible.so/reference/extract-data-from-a-document) and expand the 200 responses in the middle pane and the right pane to see the model and an example, respectively.
For the extraction results schema, see [Extract data from a document](https://docs.sensible.so/reference/extract-data-from-a-document) and expand the 200 responses in the middle pane and the right pane to see the model and an example, respectively.
### Example: Extract from PDFs in directory and output an Excel file
See the following code for an example of how to use the SDK for document extraction in your own app.
See the following code for an example of how to use the SDK for document extraction in your app.

@@ -174,2 +178,3 @@ The example:

2. Extracts data from the PDF files using the extraction configurations in a `bank_statements` document type.
4. Logs the extracted document data JSON to the console.
3. Writes the extractions to an Excel file. The Generate Excel method takes an extraction or an array of extractions, and outputs an Excel file. For more information about the conversion process, see [SenseML to spreadsheet reference](https://docs.sensible.so/docs/excel-reference).

@@ -183,3 +188,3 @@

const sensible = new SensibleSDK(apiKey);
const dir = process.argv[2];
const dir = "ABSOLUTE_PATH_TO_DOCUMENTS_DIR";
const files = (await fs.readdir(dir)).filter((file) => file.match(/\.pdf$/));

@@ -195,8 +200,12 @@ const extractions = await Promise.all(

);
await Promise.all(
const results = await Promise.all(
extractions.map((extraction) => sensible.waitFor(extraction))
);
const excel_download = await sensible.generateExcel(extractions);
console.log(excel_download);
const excelFile = await got(excel_download.url);
console.log(extractions);
console.log(results);
const excel = await sensible.generateExcel(extractions);
console.log("Excel download URL:");
console.log(excel);
const excelFile = await got(excel.url);
await fs.writeFile(`${dir}/output.xlsx`, excelFile.rawBody);

@@ -229,3 +238,3 @@ ```

const sensible = new SensibleSDK(YOUR_API_KEY);
const sensible = new SensibleSDK("YOUR_API_KEY");
const request = await sensible.classify({

@@ -242,3 +251,3 @@ path:"./boa_sample.pdf"

| ---- | ------ | ------------------------------------------------------------ |
| path | string | The path to the document you want to classify. For more information about supported file types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| path | string | The path to the document you want to classify. For information about supported file size and types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| file | string | The non-encoded bytes of the document you want to classify. |

@@ -248,2 +257,2 @@

Get results from this method by calling the Wait For method. For the schema for the results of a classification request , see [Classify document by type (sync)](https://docs.sensible.so/reference/classify-document-sync) and expand the 200 responses in the middle pane and the right pane to see the model and an example, respectively.
Get results from this method by calling the Wait For method. For the classification results schema, see [Classify document by type (sync)](https://docs.sensible.so/reference/classify-document-sync) and expand the 200 responses in the middle pane and the right pane to see the model and an example, respectively.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc