-
Notifications
You must be signed in to change notification settings - Fork 6
V2 plus #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
V2 plus #52
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 2ef6c2b
chg: :sparkles: added Custom document Class for API Builder endpoints
jonathanMindee d765c36
use specific functions for parsing
ianardee e18ed75
chg: :sparkles: allow getting api keys from env
ianardee 69ff814
pass username instead of url
ianardee 014db81
add custom docs to CLI
ianardee cc6b79d
changes for easier demo
ianardee d3330c8
refactor to allow for getting keys from envvars
ianardee e8eb625
allow printing various outputs
ianardee 1645237
use confidence instead of probability for fields
ianardee 0c42a47
package updates
ianardee 01d0aaf
better description of parse functions
ianardee d89250f
rename api_username to username
ianardee dfed771
use functions to init client
ianardee 605eba3
allow custom documents with same name as OTS
ianardee 230748e
better error message
ianardee 547f4a5
fix readme
ianardee e855a59
fix problems with envvars during testing
ianardee c039142
harmonize Document class
ianardee a4437a0
fixes for PR
ianardee 81aaa44
should be an int
ianardee 69b2b72
update readme, don't duplicate the official docs
ianardee 5c924ca
minor tweaks/fixes
ianardee 009d5af
allow setting interface version in api builder
ianardee e715e10
document api builder in readme
ianardee 06d13bf
update changelog
ianardee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.