Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5afdd89
chg: :sparkles: added support of Custom documents
jonathanMindee Jan 17, 2022
2ef6c2b
chg: :sparkles: added Custom document Class for API Builder endpoints
jonathanMindee Jan 17, 2022
d765c36
use specific functions for parsing
ianardee Jan 19, 2022
e18ed75
chg: :sparkles: allow getting api keys from env
ianardee Jan 20, 2022
69ff814
pass username instead of url
ianardee Jan 24, 2022
014db81
add custom docs to CLI
ianardee Jan 24, 2022
cc6b79d
changes for easier demo
ianardee Jan 28, 2022
d3330c8
refactor to allow for getting keys from envvars
ianardee Jan 31, 2022
e8eb625
allow printing various outputs
ianardee Feb 1, 2022
1645237
use confidence instead of probability for fields
ianardee Feb 1, 2022
0c42a47
package updates
ianardee Feb 1, 2022
01d0aaf
better description of parse functions
ianardee Feb 2, 2022
d89250f
rename api_username to username
ianardee Feb 3, 2022
dfed771
use functions to init client
ianardee Feb 3, 2022
605eba3
allow custom documents with same name as OTS
ianardee Feb 4, 2022
230748e
better error message
ianardee Feb 4, 2022
547f4a5
fix readme
ianardee Feb 4, 2022
e855a59
fix problems with envvars during testing
ianardee Feb 7, 2022
c039142
harmonize Document class
ianardee Feb 7, 2022
a4437a0
fixes for PR
ianardee Feb 7, 2022
81aaa44
should be an int
ianardee Feb 7, 2022
69b2b72
update readme, don't duplicate the official docs
ianardee Feb 8, 2022
5c924ca
minor tweaks/fixes
ianardee Feb 8, 2022
009d5af
allow setting interface version in api builder
ianardee Feb 14, 2022
e715e10
document api builder in readme
ianardee Feb 14, 2022
06d13bf
update changelog
ianardee Feb 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
- pull_request

jobs:
build:
license-check:
name: Check Licenses
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand All @@ -25,7 +26,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-lic-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-lic-

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#
# Run lint check and static code analysis.
# Run static code analysis.
#
name: Lint
name: Static Analysis

on:
- push

jobs:
build:
static-check:
name: Run Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -24,7 +25,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-dev-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-dev-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-dev-

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
- push

jobs:
build:
pytest:
name: Run Tests
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand All @@ -30,7 +31,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-test-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-test-

Expand Down
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Mindee python SDK

## v2.0.0 (2022-02-14)

### New Features
* :sparkles: Allow using custom documents (API builder)

### :boom: Breaking Changes
* :recycle: `confidence` renamed to `probability` in the return fields to match API return
* :recycle: `Client` initialization reworked to be more extensible
* :recycle: Document loading and parsing reworked to separate arguments

### Changes
* :arrow_up: Upgrade pikepdf to 4.4.1
* :memo: Documentation migrated mainly to https://developers.mindee.com/docs

## v1.3.1 (2022-02-03)

### Fixes
Expand Down Expand Up @@ -39,12 +53,12 @@

### Fix

* 🐛 Fixed [#15](https://github.com/mindee/mindee-api-python/issues/15)
* :bug: Fixed [#15](https://github.com/mindee/mindee-api-python/issues/15)

### Chg

* Added pdf page number parameter for multi-pages pdfs
* Added a blank pages only PDF detection & error raising
* :sparkles: Added pdf page number parameter for multi-pages pdfs
* :sparkles: Added a blank pages only PDF detection & error raising


## v1.2.1 (2021-09-23)
Expand Down
101 changes: 36 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,59 @@
# Mindee API helper library for Python
# Mindee API Helper Library for Python

The full documentation is available [here](https://developers.mindee.com/docs/getting-started)
## Quick Start
Here's the TL;DR of getting started.

## Requirements

This library is officially supported on Python 3.7 to 3.10.

## Install

Install from PyPi using pip, a package manager for Python.
First, get an [API Key](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key)

Then, install this library:
```shell script
pip install mindee
```

Don't have pip installed? Try installing it, by running this from the command line:

```shell script
$ curl https://bootstrap.pypa.io/get-pip.py | python
```

Getting started with the Mindee API couldn't be easier.
Create a Client and you're ready to go.

## Create your Client

The mindee.Client needs your [API credentials](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key).
You can either pass these directly to the constructor (see the code below) or via environment variables.

Depending on what type of document you want to parse, you need to add specifics auth token for each endpoint.
Finally, Python away!

### Off-the-Shelf Document
```python
from mindee import Client

mindee_client = Client(
expense_receipt_token="your_expense_receipt_api_token_here",
invoice_token="your_invoice_api_token_here",
passport_token="your_passport_api_token_here",
license_plate_token="your_license_plate_api_token_here",
raise_on_error=True
)
```

We suggest storing your credentials as environment variables.
Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.
# Init a new client and configure the Invoice API
mindee_client = Client().config_invoice("my-invoice-api-key")

# Load a file from disk and parse it
api_response = mindee_client.doc_from_path("/path/to/the/invoice.pdf").parse("invoice")

## Parsing methods
# Print a brief summary of the parsed data
print(api_response.invoice)
```

### Custom Document (API Builder)
```python
# Call the receipt parsing API and create a receipt object under parsed_data.receipt
parsed_data = mindee_client.parse_receipt("/path/to/file")

# Call the invoice parsing API and create an invoice object under parsed_data.invoice
parsed_data = mindee_client.parse_invoice("/path/to/file")
from mindee import Client

# If you have a mixed data flow of invoice and receipt, use financial_document class
# Call the invoice or receipt parsing API according to your input data type
# and create a FinancialDocument object under parsed_data.financial_document
parsed_data = mindee_client.parse_financial_document("/path/to/file")
# Init a new client and configure your custom document
mindee_client = Client().config_custom_doc(
document_type="pokemon-card",
singular_name="card",
plural_name="cards",
account_name="pikachu",
api_key="pokemon-card-api-key"
)

# Call the passport parsing API and create a Passport object under parsed_data.passport
parsed_data = mindee_client.parse_passport("/path/to/file")
# Load a file from disk and parse it
api_response = mindee_client.doc_from_path("/path/to/the/card.jpg").parse("pokemon-card")

# Call the license_plates parsing API and create a CarPlate object under parsed_data.license_plate
parsed_data = mindee_client.parse_license_plate("/path/to/file")
# Print a brief summary of the parsed data
print(api_response.card)
```

## Input data

You can pass your input file in three ways:
## Further Reading
There's more to it than that for those that need more features, or want to
customize the experience.

From file path
```python
receipt_data = mindee_client.parse_receipt('/path/to/file', input_type="path")
```
All the juicy details are described in the
**[Official Documentation](https://developers.mindee.com/docs/getting-started)**.

From a file object
```python
with open('/path/to/file', 'rb') as fp:
receipt_data = mindee_client.parse_receipt(fp, input_type="file")
```
## License
Copyright © Mindee

From a base64
```python
receipt_data = mindee_client.parse_receipt(base64_string, input_type="base64", filename="receipt.jpg")
```
Distributed under the MIT License.
Loading