Skip to main content

Mindee API helper library for Python

Project description

License: MIT GitHub Workflow Status PyPI Version Downloads

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 and add your custom endpoint (document)
mindee_client = Client(api_key="my-api-key")
custom_endpoint = mindee_client.create_endpoint(
    account_name="john",
    endpoint_name="wnine",
)

# 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 can't be determined from the class.
result = parse(product.CustomV1, endpoint=custom_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:

api_response = mindee_client.parse(
    mindee.product.InvoiceV4,
    input_source,
    page_options=mindee.PageOptions(
        page_indexes=[0, -2, -1],
        operation: mindee.PageOptions.KEEP_ONLY,
        on_min_pages=2
    )
)

Further Reading

Complete details on the working of the library are available in the following guides:

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?

Join our Slack

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mindee-4.0.1.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

mindee-4.0.1-py3-none-any.whl (110.5 kB view details)

Uploaded Python 3

File details

Details for the file mindee-4.0.1.tar.gz.

File metadata

  • Download URL: mindee-4.0.1.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for mindee-4.0.1.tar.gz
Algorithm Hash digest
SHA256 30d1d17475a31954b8b070383733dffaa51c31d60f26b508c2c455512c4e5788
MD5 eb88668a229c1c231ac5b82733985c0d
BLAKE2b-256 cf1c7e8dfc62c35f309eb8918697cfe55f4b47b08a5d35853fc2a36052f0b9dd

See more details on using hashes here.

File details

Details for the file mindee-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: mindee-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 110.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for mindee-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01ed6671e219f08f2bcd251d727ccb6a11586d70f7f8900e523785dda0fb30f8
MD5 7738775329d1bd3b72bb6e9a8e8398b4
BLAKE2b-256 6e9a7295c2fefdc4d733afe3e37423701de9fd0643ddf12fcab9b862eb196079

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page