Resistant.ai document forjerry python client for convenient integration with REST API service.
Project description
Resistant documents client
This library provides a Python client for a Resistant.ai document forgery analysis service. For a detailed description of the API please see API reference docs.
Prerequisites
During the customer onboarding process, you should be provided with the following:
- CLIENT_ID : str
- CLIENT_SECRET : str
Note: Those credentials are connected with specific environment (e.g. test, production etc.). Together with secret credentials for non-production environment you should be provided with url links:
- api_url
- token_url
Basic usage
Submit a document for analysis with default pipeline configuration.
from resistant_documents_client.client import ResistantDocumentsClient
client = ResistantDocumentsClient(client_id="CLIENT_ID", client_secret="CLIENT_SECRET")
with open("local_file.pdf", "rb") as fp:
report = client.analyze(fp.read(), query_id="local_file.pdf")
print(report["score"])
For non-production environment, provide api_url
and token_url
provided together with client secrets to client creation (ResistantDocumentsClient
).
Customized usage
Submit a document for analysis with customized process parameters or select a different type of analysis.
Step 1: Create a client with your credentials
client = ResistantDocumentsClient(client_id="CLIENT_ID", client_secret="CLIENT_SECRET")
Note: If your client secrets are for different environment than production you have to provide following api_url
token_url
. To setup proxy server URL, you can provide optional proxy
.
Step 2: Create submission with pipeline setup
with open("local_file.pdf", "rb") as fp:
my_submission_id = client.submit(fp.read(), query_id="local_file.pdf", pipeline_configuration="CONTENT_AFTER_FRAUD_AFTER_QUALITY")
Possible pipeline configurations are listed in REST API docs
Step 3: Retrieve analysis result
You can retrieve only those types of analysis which were requested in the previous step as pipeline_configuration
option.
result_content = client.content(submission_id=submission_id)
result_fraud = client.content(submission_id=submission_id)
result_quality = client.quality(submission_id=submission_id)
result_classification = client.classification(submission_id=submission_id)
print(result_content)
print(result_fraud)
print(result_quality)
print(result_classification)
These methods also accept max_num_retries
, which represents how many times the client will poll the server before failing (because the communication is asynchronous). It might be customized but has a default
value. Other parameters correspond to the ones in the REST API docs.
Other supported endpoints
submission/{submission_id}/decision
submission/{submission_id}/feedback
submission/{submission_id}/characteristics
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
Built Distribution
Hashes for resistant_documents_client-2.4.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b322395f8a6322ce478fe2b98aa5dec8a4220c8d5f46053a84a26083dcc6863 |
|
MD5 | aaf4a3b6ffc7aff7e36dbfa6753497a4 |
|
BLAKE2b-256 | 57320d9f048fd573753ee26fa3fd6f853b85a5bb56c2ffb8b46950050b708ec0 |
Hashes for resistant_documents_client-2.4.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f32c61c78692ee63f72bdfce487947ef75f384b706c6798604ba91c6e3b1341f |
|
MD5 | 105578c414995f963761d611f0dede53 |
|
BLAKE2b-256 | 666373ee6e6d8f7196dd06bd9d7760d1b7132056f3222b4f8bec6fe2b1782577 |