Mindee API helper library for Python
Project description
Mindee API Helper Library for Python
Quickly and easily connect to Mindee's API services using Python.
Quick Start
Here's the TL;DR of getting started.
First, get an API Key
Then, install this library:
pip install mindee
Finally, Python away!
Loading a File and Parsing It
Global Documents
from mindee import Client, product
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
# Parse the document as an invoice by passing the appropriate type
result = mindee_client.parse(product.InvoiceV4, input_doc)
# Print a brief summary of the parsed data
print(result.document)
Note: Files can also be loaded from:
A python BinaryIO
compatible file:
input_doc = mindee_client.source_from_file(my_file)
A URL (HTTPS
only):
input_doc = mindee_client.source_from_url("https://files.readme.io/a74eaa5-c8e283b-sample_invoice.jpeg")
A base64-encoded string, making sure to specify the extension of the file name:
input_doc = mindee_client.source_from_b64string(my_input_string, "my-file-name.ext")
Raw bytes, making sure to specify the extension of the file name:
input_doc = mindee_client.source_from_bytes(my_raw_bytes_sequence, "my-file-name.ext")
Region-Specific Documents
from mindee import Client, product
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
# Parse the document as a USA bank check by passing the appropriate type
result = mindee_client.parse(product.us.BankCheckV1, input_doc)
# Print a brief summary of the parsed data
print(result.document)
Custom Document (API Builder)
from mindee import Client, product
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Add your custom endpoint (document)
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
)
# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
# Parse the file.
# The endpoint must be specified since it cannot be determined from the class.
result = mindee_client.parse(
product.CustomV1,
input_doc,
endpoint=my_endpoint
)
# Print a brief summary of the parsed data
print(result.document)
# Iterate over all the fields in the document
for field_name, field_values in result.document.fields.items():
print(field_name, "=", field_values)
Additional Options
Options to pass when sending a file.
Page Options
Allows sending only certain pages in a PDF.
In this example we only send the first, penultimate and last pages:
from mindee import Client, product, PageOptions
result = mindee_client.parse(
product.InvoiceV4,
input_source,
page_options=PageOptions(
page_indexes=[0, -2, -1],
operation=PageOptions.KEEP_ONLY,
on_min_pages=2
)
)
Further Reading
Complete details on the working of the library are available in the following guides:
- Getting started
- Python Command Line Interface (CLI)
- Python Custom APIs (API Builder)
- Python Invoice OCR
- Python Receipt OCR
- Python Financial Document OCR
- Python Passport OCR
- Python Proof of Address OCR
- Python EU License Plate OCR
- Python FR Bank Account Detail OCR
- Python FR Carte Grise OCR
- Python FR Carte Vitale OCR
- Python FR ID Card OCR
- Python FR Petrol Receipts OCR
- Python US Bank Check OCR
- Python US W9 OCR
- Python US Driver License OCR
- Python Barcode Reader API
- Python Cropper API
- Python Invoice Splitter API
- Python Multi Receipts Detector API
You can view the source code on GitHub.
You can also take a look at the Reference Documentation.
License
Copyright © Mindee
Available as open source under the terms of the MIT License.
Questions?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mindee-4.3.0.tar.gz
.
File metadata
- Download URL: mindee-4.3.0.tar.gz
- Upload date:
- Size: 68.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c91ea1823621636c5232558801efa98d1bbd0a03ee6f4754fb75096e86668b99 |
|
MD5 | 9b8231670a4ab9c323dad2e3592c82d3 |
|
BLAKE2b-256 | 1e26dd429d3a3e1a1aa7574c984a044639ee806c8f30c8771a34149ce4533fc3 |
File details
Details for the file mindee-4.3.0-py3-none-any.whl
.
File metadata
- Download URL: mindee-4.3.0-py3-none-any.whl
- Upload date:
- Size: 120.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 920229cf23a7cd12d1a1bc47708b93b612ce34995466c5f3971746e39b503cd5 |
|
MD5 | c469b5673b3c626b6f85c36a32cdf288 |
|
BLAKE2b-256 | ed90b5eb2785cd5d0651af4ed18049e37bcaa55e04f8ee54d3d7f7ea51cfcd0a |