Sections

Agents

This object represents an agent of a user in Absurdia. The endpoints let you create an agent, retrieve agents data, update some attributes, enable/disable an agent and delete an agent.

Related doc: Accounts, Agents and Users

Agent object

An agent object returned by Absurdia's APIs will contain the following attributes:

Attributes

  • id

    string

    The ID of the agent.

  • type

    string

    One of app, shared and private. The "root agent" cannot be deleted or modified, and is the one that connects to Visage.

  • name

    string

    The name of the agent. This can be easier to use than

  • owning_user

    string

    The ID of the user who owns the agent. All agents are always owned by a single user.

  • enabled

    boolean

Whether the agent can call APIs. This will almost always be true.

  • public_key

    string | null

    A base64-encoded ed25519 public key used to verify signatures. Agents of type app do not have a public key.

  • roles

    string[]

    List of the IDs of the roles assigned to the agent.

  • metadata

    hash | null

    A hashmap of custom metadata. Values must be strings or empty. If a value is empty, the key might be used as a tag.

  • updated_at

    integer

    UNIX timestamp in microseconds of the last update on the agent.

  • created_at

    integer

    UNIX timestamp in microseconds of the creation date.

  • expire_at

    integer

    UNIX timestamp in microseconds of the expiration date of this agent.

EXAMPLE AGENT
{
    "id": "4eeaa3f9866340478fc164fde39115aa",
    "type": "app",
    "name": "Root agent",
    "owning_user": "6d0a12035235491d8605c5d811a6da8d",
    "enabled": true,
    "public_key": null,
    "roles": [
        "28259464619e4021ae732d5897060423"
    ],
    "metadata": null,
    "created_at": 1656013730610030,
    "updated_at": 1656013730610030,
    "expire_at": 4809613730610030
}

List agents

Agents of the same user as the authenticated user can use this endpoint to see all other agents of the same owner.

Request attributes

  • None

Returns

A list of agents that belongs to the requestor's user. Returns an error otherwise.

<code class="no-format"><span class="http-method-get" id="get-v1agents">GET</span> <span class="ml-2">/v1/agents</span></code> <ul class="flex flex-row text-center"><li class="mr-1"><span class="snippet-lang-select">cURL</span></li> <li class="mr-1"><span class="snippet-lang-select active">Python</span></li> <li class="mr-1"><span class="snippet-lang-select">Node/JS</span></li> <li class="mr-1"><span class="snippet-lang-select">C#</span></li></ul>
import requests

url = "https://api.absurdia.markets/v1/agents"

headers = {"Authorization": "Bearer {{token}}"}

response = requests.request("GET", url, headers=headers)

print(response.json())
Response
{
    "data": [
        //...Agent object...
    ]
}

Create an agent

signature required

An agent identifies itself to the API with a token (equivalent to an API key), holds roles to define their permissions and signs requests when needed. An agent cannot create another one with permissions that are more permissive what the agent holds.

Related doc: Agents

Request attributes

  • name required

    string

    A name for the agent.

  • description required

    string

    A description for the agent

  • type

    string

    One of private or shared. A private agent means it will only be used by you or someone in your account. A shared agent means it may be used by someone else. Default is private.

  • roles required

    string[]

    A list of the IDs of the roles assigned to the agent.

  • public_key required

    string

    The ed25519 public key of the agent. The key must be URL-safe base64 encoded.

  • metadata

    hash

    A map of metadata attached to the agent.

Returns

A dictionary with a data attribute that contains a copy the created agent. Returns an error otherwise.

<code class="no-format"><span class="http-method-post" id="post-v1agents">POST</span> <span class="ml-2">/v1/agents</span></code> <ul class="flex flex-row text-center"> <li class="mr-1"><span class="snippet-lang-select active">Python</span></li> <li class="mr-1"><span class="snippet-lang-select">Node/JS</span></li> </ul>
import requests

url = "https://api.absurdia.markets/v1/agents"

data = {
    "name": "Bot 1",
    "description": "Bot for strategy A",
    "type": "private",
    "public_key": ""
    "roles": [],
    "metadata": {
        "platform": "AWS"
    }
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer {{token}}",
    "Abs-Signature": sign(data) 
}

response = requests.request("POST", url, headers=headers, data=dump(data))

print(response.json())
Response
{
    "data": {
        //...Agent object...
    }
}

Retrieve an agent

Retrieve the agent with the given ID.

Request attributes

  • None

Returns

An agent object if the ID is valid and the requestor is authorised to read the agent. Returns an error otherwise.

<code class="no-format"><span class="http-method-get" id="get-v1agentsid">GET</span> <span class="ml-2">/v1/agents/:id</span></code> <ul class="flex flex-row text-center"><li class="mr-1"><span class="snippet-lang-select">cURL</span></li> <li class="mr-1"><span class="snippet-lang-select active">Python</span></li> <li class="mr-1"><span class="snippet-lang-select">Node/JS</span></li> </ul>
import requests

url = "https://api.absurdia.markets/v1/agents/" + agent_id

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {{token}}"
}

response = requests.request("GET", url, headers=headers)

print(response.json())
Response
{
    "data": {
        //...Agent object...
    }
}