Overview

This guide will help you extract data from Bank Statements using Butler's OCR APIs in Python. In 15 minutes you'll be ready to add Python Bank Statement OCR into your product or workflow!

Before getting started, you'll want to make sure to do the following:

  1. Signup for a free Butler account at https://app.butlerlabs.ai
  2. Write down your Butler API key from the Settings menu. Follow the Getting Started guide for more details about how to do that.

Get your API ID

Sign into the Butler product, go to the Library and search for the Bank Statement model:

2854

Click on the Bank Statements card, then press the Create button to create a new Bank Statement model:

2836

Once on the model details page, go to the APIs tab:

2854

Copy the API ID (also known as the Queue ID) and write it down. We'll use it in our code below.

Sample Python Bank Statement OCR Code

You can copy and paste the following Python sample code to process documents with OCR using the API.

# Ensure it's installed in your environment with pip install butler-sdk
from butler import Client

# Get API Key from https://docs.butlerlabs.ai/reference/uploading-documents-to-the-rest-api#get-your-api-key
api_key = '<api-key>'
# Get Queue ID from https://docs.butlerlabs.ai/reference/uploading-documents-to-the-rest-api#go-to-the-model-details-page
queue_id = '<queue_id>'

# Response is a strongly typed object
response = Client(api_key).extract_document(queue_id, 'bank_statement.jpeg')
# Convert to a dictionary for printing
print(response.to_dict())

📘

In-Product Sample Code

You can also copy the sample code directly from the product. This code will have your API ID and API Key already pre-populated for you!

Extracted Bank Statement Fields

Here is an example of what an Bank Statement JSON response looks like:

{
  "documentId": "ab85bc3a-f298-4f6a-931b-3e0396376d93",
  "documentStatus": "Completed",
  "fileName": "BS_2.jpeg",
  "mimeType": "image/jpeg",
  "documentType": "Bank Statements",
  "confidenceScore": "High",
  "formFields": [
    {
      "fieldName": "Account Number",
      "value": "00-123456",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Client Address",
      "value": "100 Pine Street\nMetro, AA 09371",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Client Name",
      "value": "Mary Jane",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Ending Balance",
      "value": "$5,710.87",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Starting Balance",
      "value": "$5,234.09",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Statement End Date",
      "value": "Apr 18, 2010",
      "confidenceScore": "High"
    },
    {
      "fieldName": "Statement Start Date",
      "value": "Mar 15, 2010",
      "confidenceScore": "High"
    }
  ],
  "tables": [
    {
      "tableName": "Transactions",
      "confidenceScore": "Low",
      "rows": [
        {
          "cells": [
            {
              "columnName": "Deposit Amount",
              "value": "272.45",
              "confidenceScore": "High"
            },
            {
              "columnName": "Deposit Date",
              "value": "Apr 8",
              "confidenceScore": "High"
            },
            {
              "columnName": "Deposit Description",
              "value": "",
              "confidenceScore": "Low"
            },
            {
              "columnName": "Withdrawal Amount",
              "value": "",
              "confidenceScore": "Low"
            },
            {
              "columnName": "Withdrawal Date",
              "value": "Apr 8",
              "confidenceScore": "High"
            },
            {
              "columnName": "Withdrawal Description",
              "value": "",
              "confidenceScore": "Low"
            }
          ]
        }
      ]
    }
  ]
}

📘

Full Bank Statement API Response

The above JSON does not include all of the values that can be extracted from Bank Statements. For full details, see the Bank Statement page.