Bank Account Details OCR

📘

This Bank account details OCR is currently available only for French bank account documents.

Mindee’s Bank account details OCR API uses deep learning to automatically, accurately, and instantaneously parse data from French RIB (Relevés d'identité Bancaire).

It takes the API a few seconds to extract data from your PDFs or photos of bank account details or RIB. The API extracts the following data:

  • Account holder name
  • IBAN
  • Swift

Set up the API

  1. You'll need a bank account details document or RIB. You can use the sample provided below.
  1. Access your Bank Account Details API dashboard by clicking on the Bank Account Details card from your APIs Store after selecting the French flag from the countries menu.
  1. On the left navigation, click on API Keys, and on the page click on the Create a new API key button
  1. Name your API key and click on the Create API key button.
  1. From the left navigation, go to documentation > API Reference, to find sample code in popular languages and command line.
curl -X POST \
  https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict \
  -H 'Authorization: Token my-api-key-here' \
  -H 'content-type: multipart/form-data' \
  -F [email protected]/path/to/your/file.png
import requests

url = "https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict"

with open("/path/to/my/file", "rb") as myfile:
    files = {"document": myfile}
    headers = {"Authorization": "Token my-api-key-here"}
    response = requests.post(url, files=files, headers=headers)
    print(response.text)
// works for NODE > v10
const axios = require('axios');
const fs = require("fs");
const FormData = require('form-data')

async function makeRequest() {
    let data = new FormData()
    data.append('document', fs.createReadStream('./file.jpg'))
    const config = {
        method: 'POST',
        url: 'https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict',
        headers: { 
          'Authorization':'Token my-api-key-here',
          ...data.getHeaders()
           },
        data
    }

    try {
      let response = await axios(config)
      console.log(response.data);
    } catch (error) {
      console.log(error)
    }

}

makeRequest()
<form onsubmit="mindeeSubmit(event)" >
  <input type="file" id="my-file-input" name="file" />
  <input type="submit" />
</form>

<script type="text/javascript">
const mindeeSubmit = (evt) => {
  evt.preventDefault()
  let myFileInput = document.getElementById('my-file-input');
  let myFile = myFileInput.files[0]
  if (!myFile) { return }
  let data = new FormData();
  data.append("document", myFile, myFile.name);

  let xhr = new XMLHttpRequest();

  xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
      console.log(this.responseText);
    }
  });

  xhr.open("POST", "https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict");
  xhr.setRequestHeader("Authorization", "Token my-api-key-here");
  xhr.send(data);
}
</script>
# tested with Ruby 2.5
require 'uri'
require 'net/http'
require 'net/https'
require 'mime/types'

url = URI("https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict")
file = "/path/to/your/file.png"

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Token my-api-key-here'
request.set_form([['document', File.open(file)]], 'multipart/form-data')

response = http.request(request)
puts response.read_body
  • Replace my-api-key-here with your new API key, or use the "select an API key" feature and it will be filled automatically.
  • Copy and paste the sample code of your desired choice into your application, code environment, or terminal.
  • Replace /path/to/my/file with the path to your invoice.
  1. Run your code. You will receive a JSON response with the invoice details.

❗️

Don't forget to replace your token!

API Response

Below is the full sample JSON response you get when you call the API. Since the response is quite verbose, we will walk through the fields section by section.

{
  "api_request": {
    "error": {},
    "resources": [
      "document"
    ],
    "status": "success",
    "status_code": 201,
    "url": "https://api.mindee.net/v1/products/mindee/bank_account_details/v1/predict"
  },
  "document": {
    "id": "65383b84-39ce-4aad-8980-3f15589dda5b",
    "name": "bank_account_details_sample.jpg",
    "n_pages": 1,
    "is_rotation_applied": true,
    "inference": {
      "started_at": "2021-05-06T16:37:28+00:00",
      "finished_at": "2022-05-11T16:02:54+00:00",
      "processing_time": 1.121,
      "pages": [
        {
          "id": 0,
          "orientation": {"value": 0},
          "prediction": { .. },
          "extras": {}
        }
      ],
      "prediction": { .. },
      "extras": {}
    }
  }
}

You can find the prediction within the prediction key found in two locations:

  • In document > inference > prediction for document-level predictions: it contains the different fields extracted at the document level, meaning that for multi-pages PDFs, we reconstruct a single passport object using all the pages.
  • In document > inference > pages[ ] > prediction for page-level predictions: it gives the prediction for each page independently. With images, there is only one element on this array, but with PDFs, you can find the extracted data for each PDF page.

Each predicted field may contain one or several values:

  • a confidence score
  • a polygon highlighting the information location
  • a page_id where the information was found (document level only)
{
 "prediction": {
   "account_holder_name": {
     "confidence": 0.98,
     "page_id": 0,
     "polygon": [[0.077, 0.842], [0.186, 0.842], [0.186, 0.856], [0.077, 0.856]],
     "value": "OLIVIER CESAR"
    },
    "iban": {
      "confidence": 0.89,
      "page_id": 0,
      "polygon": [[0.164, 0.739], [0.382, 0.739], [0.382, 0.753], [0.164, 0.753]],
      "value": "FR84 1234 5123 4512 3456 7891 A16"
    },
    "swift": {
      "confidence": 0.92,
      "page_id": 0,
      "polygon": [[0.628, 0.736], [0.808, 0.736], [0.808, 0.751], [0.628, 0.751]],
      "value": "PSSTFRPPMAR"
    }
  }
 }

Additional Attributes

Depending on the field type specified, additional attributes can be extracted from the bank account details object. Using the above RIB example, the following are the basic fields that can be extracted.

Account holder name

  • account_holder_name: In the JSON response below, we have the value of the account holder's name.
{
  "account_holder_name": {
    "confidence": 0.86,
    "page_id": 0,
    "polygon": [[0.077, 0.842], [0.186, 0.842], [0.186, 0.856], [0.077, 0.856]],
    "value": "OLIVIER CESAR"
  }
}

Iban

  • Iban: In the JSON response below, we have the value of the IBAN.
{
  "iban": {
    "confidence": 0.95,
    "page_id": 0,
    "polygon": [[0.164, 0.739], [0.382, 0.739], [0.382, 0.753], [0.164, 0.753]],
    "value": "FR84 1234 5123 4512 3456 7891 A16"
  }
}

swift

  • swift: In the JSON response below, we have the value of the swift code.
{
  "swift": {
    "confidence": 0.95,
    "page_id": 0,
    "polygon": [[0.628, 0.736], [0.808, 0.736], [0.808, 0.751], [0.628, 0.751]],
    "value": "PSSTFRPPMAR"
  }
}

 

Questions?
Slack Logo IconSlack Logo Icon  Join our Slack


Did this page help you?