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's names
- IBAN
- BBAN (Bank code, branch code, number and key)
- Swift
Set up the API
Before making any API calls, you need to have created your API key.
- You'll need a bank account details document or RIB. You can use the sample provided below.
- Access your Bank Account Details API by clicking on the Bank Account Details card in the Document Catalog.
- 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/v2/predict \\
-H 'Authorization: Token my-api-key-here' \\
-H 'content-type: multipart/form-data' \\
-F document=@/path/to/your/file.png
import json
import requests
api_key = "my-api-key-here"
account = "Mindee"
endpoint = "bank_account_details"
version = "2.0"
url = f"https://api.mindee.net/v1/products/{account}/{endpoint}/v{version}/predict"
with open("/path/to/the/file.ext", "rb") as file_handle:
files = {"document": file_handle}
headers = {"Authorization": f"Token {api_key}"}
response = requests.post(url, files=files, headers=headers)
json_response = response.json()
if not response.ok:
raise RuntimeError(json_response["api_request"]["error"])
print(json.dumps(json_response["document"], indent=2))
// works for NODE > v10
const axios = require("axios");
const fs = require("fs");
const FormData = require("form-data");
const apiKey = "my-api-key-here";
const account = "Mindee";
const endpoint = "bank_account_details";
const version = "2.0";
async function makeRequest(filePath) {
let data = new FormData();
data.append("document", fs.createReadStream(filePath));
const config = {
method: "POST",
url: `https://api.mindee.net/v1/products/${account}/${endpoint}/v${version}/predict`,
headers: {
Authorization: `Token ${apiKey}`,
...data.getHeaders()
},
data
}
try {
let response = await axios(config)
console.log(response.data);
} catch (err) {
console.error(err);
process.exit(1);
}
}
makeRequest("/path/to/the/file.ext");
using Mindee;
using Mindee.Parsing;
string apiKey = "my-api-key-here";
string filePath = "/path/to/the/file.ext";
MindeeClient mindeeClient = MindeeClientInit.Create(apiKey);
CustomEndpoint myEndpoint = new CustomEndpoint(
endpointName: "bank_account_details",
accountName: "Mindee",
version: "2.0"
);
var documentParsed = await mindeeClient
.LoadDocument(new FileInfo(filePath))
.ParseAsync(myEndpoint);
System.Console.WriteLine(documentParsed.ToString());
<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/v2/predict");
xhr.setRequestHeader("Authorization", "Token my-api-key-here");
xhr.send(data);
}
</script>
require 'uri'
require 'net/http'
require 'net/https'
url = URI('https://api.mindee.net/v1/products/mindee/bank_account_details/2.0/predict')
file = '/path/to/the/file.ext'
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
import com.mindee.MindeeClient;
import com.mindee.MindeeClientInit;
import com.mindee.DocumentToParse;
import com.mindee.parsing.common.Document;
import com.mindee.parsing.custom.CustomV1Inference;
import com.mindee.parsing.CustomEndpoint;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException {
String apiKey = "my-api-key-here";
String filePath = "/path/to/the/file.ext";
MindeeClient mindeeClient = MindeeClientInit.create(apiKey);
DocumentToParse docToParse = new DocumentToParse(new File(filePath));
CustomEndpoint customEndpoint = new CustomEndpoint(
"bank_account_details",
"Mindee",
"2.0"
);
Document<CustomV1Inference> documentParsed = mindeeClient.parse(
docToParse,
customEndpoint
);
System.out.println(documentParsed.toString());
}
}
- 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.
- Run your code. You will receive a JSON response with the invoice details.
Always remember to replace your API key!
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/v2/predict"
},
"document": {
"id": "65383b84-39ce-4aad-8980-3f15589dda5b",
"name": "bank_account_details_sample.jpg",
"n_pages": 1,
"is_rotation_applied": true,
"inference": {
"started_at": "2023-06-16T13:22:40.382074",
"finished_at": "2023-06-16T13:22:41.498981",
"processing_time": 1.117,
"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_holders_names": {
"confidence": 0.98,
"page_id": 0,
"polygon": [[0.046, 0.841],[0.19, 0.841],[0.19, 0.858],[0.046, 0.858]],
"value": "MR OLIVIER CESAR"
},
"bban": {
"bban_bank_code": "12345",
"bban_branch_code": "12345",
"bban_key": "16",
"bban_number": "1234567891A",
"confidence": 0.56,
"page_id": 0,
"polygon": [[0.122, 0.616],[0.44, 0.616],[0.44, 0.754],[0.122, 0.754]]
},
"iban": {
"confidence": 0.99,
"page_id": 0,
"polygon": [[0.122, 0.74],[0.384, 0.74],[0.384, 0.754],[0.122, 0.754]],
"value": "FR8412345123451234567891A16"
},
"swift": {
"confidence": 0.95,
"page_id": 0,
"polygon":[[0.628, 0.738],[0.809, 0.738],[0.809, 0.754],[0.628, 0.754]],,
"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_holders_names: In the JSON response below, we have the value of the account holder's names outputted as a single string including civilities.
{
"account_holders_names": {
"confidence": 0.98,
"page_id": 0,
"polygon": [[0.046, 0.841],[0.19, 0.841],[0.19, 0.858],[0.046, 0.858]],
"value": "MR OLIVIER CESAR"
}
}
BBAN
- bban: In the JSON response below we have the list of values of the bban. For French Bank Account Details only.
- bban_bank_code: The bank code outputted as a string.
- bban_branch_code: The branch code outputted as a string.
- bban_number: The bban number outputted as a string.
- bban_key: The BBAN key outputted as a string
{
"bban": {
"bban_bank_code": "12345",
"bban_branch_code": "12345",
"bban_key": "16",
"bban_number": "1234567891A",
"confidence": 0.56,
"page_id": 0,
"polygon": [[0.122, 0.616],[0.44, 0.616],[0.44, 0.754],[0.122, 0.754]]
}
}
IBAN
- Iban: In the JSON response below, we have the value of the IBAN.
{
"iban": {
"confidence": 0.99,
"page_id": 0,
"polygon": [[0.122, 0.74],[0.384, 0.74],[0.384, 0.754],[0.122, 0.754]],
"value": "FR8412345123451234567891A16"
},
}
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.738],[0.809, 0.738],[0.809, 0.754],[0.628, 0.754]],,
"value": "PSSTFRPPMAR"
}
}
Questions?
Join our Slack
Updated 2 months ago