Skip to main content

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)

print(result_content)
print(result_fraud)
print(result_quality)

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resistant_documents_client-2.4.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resistant_documents_client-2.4.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file resistant_documents_client-2.4.0.tar.gz.

File metadata

  • Download URL: resistant_documents_client-2.4.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.15 Linux/5.13.0-1022-aws

File hashes

Hashes for resistant_documents_client-2.4.0.tar.gz
Algorithm Hash digest
SHA256 ff3e296234a969443d81516b0b4776c226656880779337a5eed35d0282467101
MD5 acdfce01903715458dc174f077eb6d39
BLAKE2b-256 f2f7c58fb3fb7b84a24406770243228a8f488dd75a00f8b356429b464df32556

See more details on using hashes here.

File details

Details for the file resistant_documents_client-2.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for resistant_documents_client-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c529408e516255da04901a749f4d2d2867db746f0e0fb3936c996b9b970b7d18
MD5 759a6a2b32693aaf03eaa0468cb628fd
BLAKE2b-256 f377f81f1a2e063a0332b54232f600f9930b837770c9e54f7a909eaf4073593e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page