Skip to main content

Helper library for consuming the Unmand API

Project description

Unmand Python Library

Version

The Unmand Python library provides convenient access to the Unmand APIs from applications written in the Python language.

For more help, see our docs.

Requirements

Python 3+

Installation

Install the package with:

pip install unmand

Example Usage

from unmand import Extraction, ExfilAPI

token = 'TOP-SECRET-EXAMPLE-TOKEN'
document_path = 'Sample.pdf'

exfil = ExfilAPI(token)
with open(document_path, 'rb') as file_data:
    extraction = exfil.queue(file_data)
    print(extraction)
    if extraction.status != "FAILED":
        exfil.poll(extraction=extraction)
        if extraction.status == 'FINISHED':
            print(extraction.result)

ExfilAPI and Extraction

The main class is ExfilAPI. Instantiate this with your token argument. Use the optional argument test to direct your queries to the test API instead of the production API. For example:

exfil_test = ExfilAPI(token, test=True) # This aims at the test API
exfil = ExfilAPI(token) # This aims at the production API

Submit a extraction by attaching the binary file data from your system to the queue method of ExfilAPI. This will return an instance of the Extraction class.

extraction = exfil.queue(file_data)

At any time, you can get the status of the extraction:

print(extraction) # or
print(extraction.status)

Once a extraction is queued, call the poll method of the ExfilAPI class to be updated when the extraction is finished. Use the optional argument suppress_output to stop updates printing to screen.

exfil.poll(extraction=extraction)  # or
exfil.poll(extraction=extraction, suppress_output=True)

Once finished, the results of the extraction are saved as a dictionary under the result attribute.

print(extraction.result)

Swarm Tasks

There is a SwarmAPI class so that swarm tasks can be uploaded for display in the UI. An example usage is shown below. Be careful, the token for a Swarm project will be different.

swarm = SwarmAPI(token, test=True)

start_time = datetime.utcnow()
finish_time = datetime.utcnow()
response_details = {'Some data': 1, 'Some other data': 2, "an array": [1,2,3,4]}
status = 'SUCCESS' # or 'FAILURE'

task = Task('UniqueTestId', start_time, finish_time , status, 'PROD', 'Short Response', response_details , "First Identifier", "Second Identifier", "Third Identifier")
swarm.upload_swarm_task(task)

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

unmand-2.1.2.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

unmand-2.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file unmand-2.1.2.tar.gz.

File metadata

  • Download URL: unmand-2.1.2.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for unmand-2.1.2.tar.gz
Algorithm Hash digest
SHA256 3dbc142283b2c1623eb97d5a25770b710a892caf590527521096961faed9266c
MD5 e2b3b929bbacc883407aeec173092fd9
BLAKE2b-256 b96f60926224ecab4546657b6ebb634b3f9891d2438be5da39ed3f3068df7f01

See more details on using hashes here.

File details

Details for the file unmand-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: unmand-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for unmand-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0abc8f752b66c15c4fe4fb3f7c5133fe0c093984c20ea37f45a26451ae6e3296
MD5 ef44d82335dcbc53dcce4efb0a8502e0
BLAKE2b-256 88ec831cb4f65f64b0bd54da1c58343829f2a44ed24df75904dcc1ae33002025

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