Examples
Python
Run a task and wait for the result.
import os, time, requests
H = {"Authorization": f"Bearer {os.environ['TAKEN_API_KEY']}"}
task = requests.post("https://taken.trade/api/public/v1/agent/tasks", headers=H,
json={"instruction": "Open example.com and tell me the page title"}, timeout=60).json()["data"]
while True:
t = requests.get(f"https://taken.trade/api/public/v1/agent/tasks/{task['id']}", headers=H, timeout=90).json()["data"]
print(t["status"], "-", t["events"][-1]["message"] if t["events"] else "")
if t["done"]:
print("Result:", t["result"]); break
time.sleep(1)