Python interface to Basylic's API
Project description
basylic-python-client
Class to access Basylic API
Summary
Developed by ETAONIS, Basylic is a SaaS solution performing document fraud detection with "state-of-the-art" performances. The solution is also used as a powerful tool to extract information from documents. This module provides a Python interface for accessing Basylic.
Installation
This module is available on PyPI. You can install it with pip
command:
pip install basylic
Alternatively, you can access the module source code on GitHub:
Basic usage
To access the API, a token must be provided. We recommend you to store this token as an environment variable called BASYLIC_ACCESS_TOKEN
and then import the module.
from basylic import Basylic
basylic = Basylic()
Alternatively, if your token is stored in a non-standard location, you can specify it with argument token
during class instantiation:
from basylic import Basylic
basylic = Basylic(token=...)
- Two arguments are mandatory:
file_path
anddocument_type
:
basylic.send_document(file_path = "corinne-berthier-recto-verso.pdf", document_type="french_ids")
- The
file_path
argument is a string with the document path (e.g.: "~/FILE.pdf") document_type
is a string specifying which Basylic API to call (e.g.: "french_ids")
Possible values for document_type
are: 'french_ids'
, 'rib'
, 'ri'
, 'avis-imposition'
...
With those arguments specified, send_document
returns a comprehensive JSON document.
- Data about applicants can also be joined to the API call:
applicants_information = {"applicant_0": {"identity": "BERTHIER CORINNE"}}
basylic_result = basylic.send_document(
file_path="corinne-berthier-recto-verso.pdf",
document_type="french_ids", applicants_information=applicants_information)
print(basylic_result)
- And various arguments could be passed as kwargs. For example:
- a.
save_report=True
will save the result of your request in your user space on Basylic Portal; - b.
with_image=True
will return a base64 image for each recognised document; - c.
reference='abc...'
will add a key-value pair to the API output. If this key is specified, the report will appear under this reference in Basylic Portal.
For example, this code:
applicants_information = {"applicant_0": {"identity": "BERTHIER CORINNE"}}
basylic_result = basylic.send_document(
file_path="corinne-berthier-recto-verso.pdf",
document_type="french_ids", applicants_information=applicants_information,
with_image=True, reference="XX45678-BERTH-PARIS", save_report=True)
print(basylic_result)
will act in the following way:
- Upload of document whose path is
file_path
to Basylic servicefrench_ids
; - Produce of a JSON document
basylic_result
with all relevant information; - Compare
identity
provided and identity extracted by Basylic OCR; - A base64 encoded image will be returned in the approriate key of
7basylic_result
; - The reference
XX45678-BERTH-PARIS
will be included inbasylic_result
and used as reference in Basylic's Portal.
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
File details
Details for the file basylic-0.12.1.tar.gz
.
File metadata
- Download URL: basylic-0.12.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 529478fd337114cf51ec18f941d15dbe12b12e78bde5afad18345c1a3612dd5b |
|
MD5 | f056a7579514110899f132aa4af572fd |
|
BLAKE2b-256 | af8b5b0b0f6944f5c2d9f61ba9da186f7b932dde33fc0ebc53eff3f11f172fb6 |