Use Sensible’s Node SDK to directly integrate Sensible’s document extraction and classification APIs into your product. With the Sensible SDK you can easily extract key information from your custom documents, powered by Sensible’s developer platform.
What we'll cover
This blog post briefly walks you through installing the Sensible Node SDK and integrating it into an example application. You’ll extract data from a directory of documents, view the data as JSON, and convert the data to Excel. To follow along with this tutorial, you'll need:
- Node installed (any version that’s not end-of-life)
- Basic knowledge of Node
- A code editor, i.e., VS Code
Example app scenario
Imagine you’re a startup that helps homeowners connect to lenders and government subsidies for energy-efficient home improvements. As part of qualifying your potential borrowers, you ask them to upload 3 recent bank statements. You need to extract data from the bank statements and get it into a backend database as part of your business logic.
Take the following steps to extract sample data from bank statements with the Sensible Node SDK.
1. Get a Sensible account
2. Install the Sensible SDK
In an environment with Node installed, open a command prompt and enter the following commands to create a test project:
Then, install the SDK:
3. Download example bank statements
To extract real document data in this tutorial, you’ll use a collection of example bank statements. In your test project, open a command prompt and enter the following commands to download and unzip the sample documents:
4. Configure extractions for bank statements
To add extraction configurations for bank statements to your Sensible account, follow the steps in Out-of-the-box extractions.
Explanation: For this tutorial, we’ll skip writing extraction configurations from scratch, and use Sensible’s pre-built, open-source configuration library. This step adds a bank_statements document type in the Sensible app from the Sensible configuration library. The document type is an API endpoint, which you’ll call later in this tutorial. It contains a collection of SenseML extraction configurations, one for each of your target banks, for example Bank of America, Chase, and so forth.
5. Extract document data
See the following code for a working example of how to use the SDK for document extraction in your own app.
- Filters a directory to find PDF files.
- Extracts data from the PDF files using the extraction configurations in a bank_statements document type.
- Prints extraction results to the console.
- Compiles the extractions into an Excel file.
To run the preceding code example, take the following steps:
1. Paste the preceding code into your empty index.mjs file.
2. Configure your environment so that your SENSIBLE_APIKEY specifies your API key.
3. In a command prompt in the same directory as your index.mjs file, run the code with the following command:
6. Check results
You should see results like the following excerpted response, which show a couple of extraction results.
Note: You'll notice several fields are null, because the example documents are redacted.
Note To access data in the parsed_document object, for example to see details of transactions in the Accounts object, you can add statements similar to the following to your script:
If you add the preceding code, you should see results like the following logged to the console for each extraction:
You can import the extracted document data as JSON into your database, or for a quick view of the data, you can take a look at the Excel file the script also generated.
Sensible’s SDK gives you convenient access to the powerful and flexible Sensible developer platform for intelligent document automation. Once you’ve configured your extractions in the Sensible app, integrating is as easy as a few lines of SDK code. Then you’ve got the structured and typed document data at your fingertips as JSON or Excel data.