Skip to main content

In order to use this library, you need to have an Anymate account. Please visit anymate.io for more information.


Anymate Python SDK is written in Python 3. The SDK is available as open source and can be found on our github page. You can find the documentation for the SDK as part of the Anymate Developer docs.

We have also published it at pypi.org. Installing the Anymate package is done with the following command:

    #Install through pip
    pip install --upgrade anymate

Once installed, you just need to import anymate in your python program and you are ready to go

   import anymate

After anymate has been imported, you have to initialize the client to communicate with Anymate. The functions exposed in the client mirror the endpoints available in the API. We recommend going to the individual pages to learn more.

The SDK is built to automatically take care of authentication with Anymate as well as refreshing access_tokens as needed. Once the anymate.client is initialized, you don't have to worry about it.

You can see an example of a simple automation based on the Allocator Pattern below, where the automation script is working in one process and creating new tasks in another.

    #Import the anymate library
    import anymate


    #Setting up variables for future use
    client_id = "My client id"
    client_secret = "My API secret"
    username = "Mate Username"
    password = "Mate Password"

    #The process where the script is working
    myProcessKey = "myProcessKey"

    #The target Process where we want to create tasks in
    targetProcessKey = "targetProcessKey"
    
    #Initialize the client
    client = anymate.client(client_id, client_secret, username, password)

    #Check if the script should start work
    is_ok_to_run = client.OkToRun(myProcessKey)
    if not is_ok_to_run.okToRun:
       #If there is nothing to do, then stop the script here
       return

    # Business logic not included. We assume that "new_tasks" is an array with objects ready for anymate.

    #Let Anymate know that work has begun
    run = client.start_or_get_run(myProcessKey)

    for task in new_tasks:
        #create a task for each object in the array 'new_tasks'
        client.create_task(targetProcessKey, task)
    
    #Let Anymate know the work is done
    client.finish_run(dict(runId=run.runId))

      

Making a script to take Tasks from the Queue and perform work on them is equally simple.

# Import the anymate library
import anymate

# Setting up variables for future use
client_id = "My client id"
client_secret = "My API secret"
username = "Mate Username"
password = "Mate Password"

# The process where the script is working
myProcessKey = "myProcessKey"


# Initialize the client
client = anymate.client(client_id, client_secret, username, password)

# Check if the script should start work
is_ok_to_run = client.OkToRun(myProcessKey)
if not is_ok_to_run.okToRun:
    # If there is nothing to do, then stop the script here
    return

# Business logic not included. We assume that "new_tasks" is an array with objects ready for anymate.

# Take first task from the queue - notice it is returned as a dictionary
task = client.take_next(myProcessKey)

#Our workloop continues while the TaskId is above 0. If the queue is empty, the TaskId will be -1.
while task['taskId'] > 0:
    #Businesslogic omitted. We have created a dummy function to take the Task as input and return if it is solved (true) or goes to manual (false)
    task_is_solved = PerformBusinessLogic(task)
    if task_is_solved:
        #Task was solved - solved and manual takes both dictionaries and objects, as long as they have the right keys/attributes.
        solved_result = client.solved(dict(taskId=task['taskId'], reason='Solved', comment = 'Task was solved'))
    else:
        #Send task to Manual
        manual_result = client.manual(dict(taskId=task['taskId'], reason='Manual', comment='Task was sent to Manual'))

    #Logic to handle exceptions and errors omitted
    task = client.take_next(myProcessKey)

Enterprise On-Premises

The anymate SDK supports customers who have Anymate installed On-Premises with an Enterprise license out of the box. In order to let anymate know you are running on a on-premises license, simply initialize the client with On Premises mode enabled.

import anymate

# Initialize Client as always
client_id = "My client id"
client_secret = "My API secret"
username = "Mate Username"
password = "Mate Password"
client = anymate.client(client_id, client_secret, username, password)

#Define a Client uri and an auth uri
client_base_uri = "http://localanymate
auth_base_uri = "http://localanymateauth

#Set On Premises mode
client.set_on_premises_mode(client_base_uri, auth_base_uri)

#From here on, you can use the client as you otherwise would

Metadata

Release files for anymate 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for anymate 1.0.13
File Interpreter ABI Platform Actions
anymate-1.0.13-py3-none-any.whl Python 3 none any Details for anymate-1.0.13-py3-none-any.whl

Release files / anymate-1.0.13-py3-none-any.whl

Download URL anymate-1.0.13-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bd631c0299a9359a9e111beb22a26089ac0e302c39873614ec1515db9e1201e
BLAKE2b-256 checksum
How to use checksums
89a4516140e2e8c044c6ec6d2b872e213ff8ccc5c75cde182a646f5f7ab27d3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Security for anymate 1.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page