Socket
Socket
Sign inDemoInstall

sensible-api

Package Overview
Dependencies
30
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.6 to 0.0.7

2

package.json
{
"name": "sensible-api",
"version": "0.0.6",
"version": "0.0.7",
"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"],

# Sensible Node SDK
Welcome! Sensible is a developer-first platform for extracting structured data from documents, for example, business forms in PDF format. use Sensible to build document-automation features into your SaaS products. Sensible is highly configurable: you can get simple data [in minutes](https://docs.sensible.so/docs/getting-started-ai) by leveraging GPT-4 and other large-language models (LLMs), or you can tackle complex and idiosyncratic document formatting with Sensible's powerful [layout-based document primitives](https://docs.sensible.so/docs/getting-started).
Welcome! Sensible is a developer-first platform for extracting structured data from documents, for example, business forms in PDF format. use Sensible to build document-automation features into your SaaS products. Sensible is highly configurable: you can get simple data [in minutes](https://docs.sensible.so/docs/getting-started-ai) by leveraging GPT-4 and other large-language models (LLMs), or you can tackle complex and idiosyncratic document formatting with Sensible's powerful [layout-based document primitives](https://docs.sensible.so/docs/getting-started).

@@ -10,8 +10,8 @@ ![Click to enlarge](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/images/final/intro_SDK_2.png)

- [Extract](#extract-document-data): Extract structured data from your custom documents. Configure the extractions for a set of similar documents, or *document type*, in the Sensible app or Sensible API, then run extractions for documents of the type with this SDK.
- [Classify](#classify): Classify documents by the types you define, for example, bank statements or tax forms. Use classification to determine which documents to extract prior to calling a Sensible extraction endpoint, or route each document in a system of record.
- [Extract](#usage-extract-document-data): Extract structured data from your custom documents. Configure the extractions for a set of similar documents, or *document type*, in the Sensible app or Sensible API, then run extractions for documents of the type with this SDK.
- [Classify](#usage-classify-documents-by-type): Classify documents by the types you define, for example, bank statements or tax forms. Use classification to determine which documents to extract prior to calling a Sensible extraction endpoint, or route each document in a system of record.
## Documentation
- For extraction and classification response schemas, see [Sensible API](https://docs.sensible.so/reference/choosing-an-endpoint).
- For extraction and classification response schemas, see the [Sensible API reference](https://docs.sensible.so/reference/choosing-an-endpoint).
- For configuring document extractions, see [SenseML reference](https://docs.sensible.so/docs/senseml-reference-introduction).

@@ -37,3 +37,3 @@

To import Sensible and other dependencies to your project, create an `index.mjs` file in your test project, and add the following lines to the file:
To import Sensible to your project, create an `index.mjs` file in your test project, and add the following lines to the file:

@@ -48,3 +48,3 @@ ```node

To initialize the dependency, paste the following code into your `index.mjs` file and replace `YOUR_API_KEY` with your [API key](https://app.sensible.so/account/).
To initialize the SDK, paste the following code into your `index.mjs` file and replace `YOUR_API_KEY` with your [API key](https://app.sensible.so/account/):

@@ -55,3 +55,3 @@ ```node

**Note** In production ensure you secure your API key, for example as a GitHub secret.
**Note:** Ensure you secure your API key in production, for example as a GitHub secret.

@@ -66,3 +66,3 @@ ## Quickstart

```node
import { SensibleSDK } from "sensible-api"
import { SensibleSDK } from "sensible-api";

@@ -73,3 +73,3 @@ const sensible = new SensibleSDK(YOUR_API_KEY); //replace with your API key

documentType: "sensible_instruct_basics",
environment: "development"
environment: "development"
});

@@ -80,3 +80,3 @@ const results = await sensible.waitFor(request); // polls every 5 seconds. Optional if you configure a webhook

2. Replace `YOUR_API_KEY` with your [API key](https://app.sensible.so/account/):
2. Replace `YOUR_API_KEY` with your [API key](https://app.sensible.so/account/).
3. In a command prompt in the same directory as your `index.mjs` file, run the code with the following command:

@@ -111,3 +111,3 @@

Navigate to https://app.sensible.so/editor/instruct/?d=sensible_instruct_basics&c=contract&g=contract to see how the extraction you just ran works in the Sensible app. You can add more fields to the left pane to extract more data:
Navigate to the example in the [SenseML editor](https://app.sensible.so/editor/?d=sensible_instruct_basics&c=contract&g=contract) to see how the extraction you just ran works in the Sensible app. You can add more fields to the left pane to extract more data:

@@ -124,8 +124,8 @@ ![Click to enlarge](https://raw.githubusercontent.com/sensible-hq/sensible-docs/main/readme-sync/assets/v0/images/final/sdk_node_1.png)

1. Instantiate an SDK object with `new SensibleSDK()`.
1. Instantiate an SDK object with `new SensibleSDK()`.
2. Request a document extraction with `sensible.extract()`. Use the following required parameters:
1. **(required)** Specify the document from which to extract data using the `url`, `path`, or `file` parameter.
1. **(required)** Specify the document from which to extract data using the `url`, `path`, or `file` parameter.
2. **(required)** Specify the user-defined document type or types using the `documentType` or `documentTypes` parameter.
3. Wait for the result. Use `sensible.waitFor()`, or use a webhook.
4. Optionally convert extractions to Excel file with `generateExcel()`.
3. Wait for the results. Use `sensible.waitFor()`, or use a webhook.
4. Optionally convert extractions to an Excel file with `generateExcel()`.
5. Consume the data.

@@ -142,2 +142,4 @@

documentType: "tax_forms",
configurationName: "1040_2021",
"environment": "development",
webhook: {

@@ -153,9 +155,9 @@ url:"YOUR_WEBHOOK_URL",

| ----------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| path | string | An option for submitting the document you want to extract data from.<br/> Pass the path to the document. For more information about supported file types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| file | string | An option for submitting the document you want to extract data from.<br/> Pass the non-encoded document bytes. |
| url | string | An option for submitting the document you want to extract data from.<br/>URL that responds to a GET request with the bytes of the document you want to extract data from. This URL must be either publicly accessible, or presigned with a security token as part of the URL path. 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. |
| documentType | string | An option for specifying the document type or types.<br/>Type of document to extract from. Create your custom type in the Sensible app (for example, `rate_confirmation`, `certificate_of_insurance`, or `home_inspection_report`). |
| documentTypes | array | An option for specifying the document type or types.<br/>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 best-scoring extraction in the document type.<br/>If unspecified, Sensible automatically detects the best-fit extraction from among the extraction queries ("configs") in the document type.<br/>Not applicable for portfolios. |
| documentName | string | If you specify the filename of the document using this parameter, then Sensible returns the filename in the extraction response and populates the file name in the Sensible app's list of recent extractions. |
| 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). |
| file | string | The non-encoded bytes of the document you want to extract from. |
| 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. |
| documentType | string | Type of document to extract from. Create your custom type in the Sensible app (for example, `rate_confirmation`, `certificate_of_insurance`, or `home_inspection_report`), or use Sensible's library of out-of-the-box supported document types. |
| 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. |
| 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. |

@@ -172,3 +174,3 @@ | 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. |

See the following code for a complete 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 own app.

@@ -229,3 +231,3 @@ The example:

```node
import { SensibleSDK } from "sensible-api"
import { SensibleSDK } from "sensible-api";

@@ -244,4 +246,4 @@ const sensible = new SensibleSDK(YOUR_API_KEY);

| ---- | ------ | ------------------------------------------------------------ |
| path | string | An option for submitting the document you want to extract data from. Pass the path to the document. For more information about supported file types, see [Supported file types](https://docs.sensible.so/docs/file-types). |
| file | string | Pass the non-encoded document bytes. For 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 more information about supported file 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. |

@@ -251,4 +253,1 @@ ### Classification results

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.
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