Skip to content

Commit f244778

Browse files
Version 2.0.0 (#52)
* chg: ✨ added support of Custom documents * refactor to allow for getting keys from envvars * allow printing various outputs * use confidence instead of probability for fields * use functions to init client * allow custom documents with same name as OTS * harmonize Document class * update readme, don't duplicate the official docs * allow setting interface version in api builder * update changelog Co-authored-by: mohamedmindee <jonathan@mindee.co>
1 parent 30d38ce commit f244778

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+21445
-1659
lines changed

.github/workflows/license.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- pull_request
88

99
jobs:
10-
build:
10+
license-check:
11+
name: Check Licenses
1112
runs-on: ubuntu-latest
1213
timeout-minutes: 30
1314
strategy:
@@ -25,7 +26,7 @@ jobs:
2526
uses: actions/cache@v2
2627
with:
2728
path: ~/.cache/pip
28-
key: ${{ runner.os }}-lic-${{ hashFiles('**/requirements.txt') }}
29+
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.py') }}
2930
restore-keys: |
3031
${{ runner.os }}-lic-
3132

.github/workflows/linting.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#
2-
# Run lint check and static code analysis.
2+
# Run static code analysis.
33
#
4-
name: Lint
4+
name: Static Analysis
55

66
on:
77
- push
88

99
jobs:
10-
build:
10+
static-check:
11+
name: Run Static Analysis
1112
runs-on: ubuntu-latest
1213
strategy:
1314
matrix:
@@ -24,7 +25,7 @@ jobs:
2425
uses: actions/cache@v2
2526
with:
2627
path: ~/.cache/pip
27-
key: ${{ runner.os }}-dev-${{ hashFiles('**/requirements.txt') }}
28+
key: ${{ runner.os }}-dev-${{ hashFiles('**/setup.py') }}
2829
restore-keys: |
2930
${{ runner.os }}-dev-
3031

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
- push
88

99
jobs:
10-
build:
10+
pytest:
11+
name: Run Tests
1112
runs-on: ubuntu-latest
1213
timeout-minutes: 30
1314
strategy:
@@ -30,7 +31,7 @@ jobs:
3031
uses: actions/cache@v2
3132
with:
3233
path: ~/.cache/pip
33-
key: ${{ runner.os }}-test-${{ hashFiles('**/requirements.txt') }}
34+
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.py') }}
3435
restore-keys: |
3536
${{ runner.os }}-test-
3637

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Mindee python SDK
22

3+
## v2.0.0 (2022-02-14)
4+
5+
### New Features
6+
* :sparkles: Allow using custom documents (API builder)
7+
8+
### :boom: Breaking Changes
9+
* :recycle: `confidence` renamed to `probability` in the return fields to match API return
10+
* :recycle: `Client` initialization reworked to be more extensible
11+
* :recycle: Document loading and parsing reworked to separate arguments
12+
13+
### Changes
14+
* :arrow_up: Upgrade pikepdf to 4.4.1
15+
* :memo: Documentation migrated mainly to https://developers.mindee.com/docs
16+
317
## v1.3.1 (2022-02-03)
418

519
### Fixes
@@ -39,12 +53,12 @@
3953

4054
### Fix
4155

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

4458
### Chg
4559

46-
* Added pdf page number parameter for multi-pages pdfs
47-
* Added a blank pages only PDF detection & error raising
60+
* :sparkles: Added pdf page number parameter for multi-pages pdfs
61+
* :sparkles: Added a blank pages only PDF detection & error raising
4862

4963

5064
## v1.2.1 (2021-09-23)

README.md

Lines changed: 36 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,59 @@
1-
# Mindee API helper library for Python
1+
# Mindee API Helper Library for Python
22

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

5-
## Requirements
6-
7-
This library is officially supported on Python 3.7 to 3.10.
8-
9-
## Install
10-
11-
Install from PyPi using pip, a package manager for Python.
6+
First, get an [API Key](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key)
127

8+
Then, install this library:
139
```shell script
1410
pip install mindee
1511
```
1612

17-
Don't have pip installed? Try installing it, by running this from the command line:
18-
19-
```shell script
20-
$ curl https://bootstrap.pypa.io/get-pip.py | python
21-
```
22-
23-
Getting started with the Mindee API couldn't be easier.
24-
Create a Client and you're ready to go.
25-
26-
## Create your Client
27-
28-
The mindee.Client needs your [API credentials](https://developers.mindee.com/docs/make-your-first-request#create-an-api-key).
29-
You can either pass these directly to the constructor (see the code below) or via environment variables.
30-
31-
Depending on what type of document you want to parse, you need to add specifics auth token for each endpoint.
13+
Finally, Python away!
3214

15+
### Off-the-Shelf Document
3316
```python
3417
from mindee import Client
3518

36-
mindee_client = Client(
37-
expense_receipt_token="your_expense_receipt_api_token_here",
38-
invoice_token="your_invoice_api_token_here",
39-
passport_token="your_passport_api_token_here",
40-
license_plate_token="your_license_plate_api_token_here",
41-
raise_on_error=True
42-
)
43-
```
44-
45-
We suggest storing your credentials as environment variables.
46-
Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.
19+
# Init a new client and configure the Invoice API
20+
mindee_client = Client().config_invoice("my-invoice-api-key")
4721

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

49-
## Parsing methods
25+
# Print a brief summary of the parsed data
26+
print(api_response.invoice)
27+
```
5028

29+
### Custom Document (API Builder)
5130
```python
52-
# Call the receipt parsing API and create a receipt object under parsed_data.receipt
53-
parsed_data = mindee_client.parse_receipt("/path/to/file")
54-
55-
# Call the invoice parsing API and create an invoice object under parsed_data.invoice
56-
parsed_data = mindee_client.parse_invoice("/path/to/file")
31+
from mindee import Client
5732

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

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

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

70-
## Input data
71-
72-
You can pass your input file in three ways:
49+
## Further Reading
50+
There's more to it than that for those that need more features, or want to
51+
customize the experience.
7352

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

79-
From a file object
80-
```python
81-
with open('/path/to/file', 'rb') as fp:
82-
receipt_data = mindee_client.parse_receipt(fp, input_type="file")
83-
```
56+
## License
57+
Copyright © Mindee
8458

85-
From a base64
86-
```python
87-
receipt_data = mindee_client.parse_receipt(base64_string, input_type="base64", filename="receipt.jpg")
88-
```
59+
Distributed under the MIT License.

0 commit comments

Comments
 (0)