Introduction
The REST API is automatically documented using OpenAPI. By
default, the server binds at http://localhost:9999.
| URL | Description |
|---|---|
http://localhost:9999/docs |
Swagger UI: interactive reference. |
http://localhost:9999/redoc |
ReDoc: readable reference. |
To prevent server fingerprinting or information leakage, the documentation pages are
only accessible via localhost external clients cannot access them.
Note
The websocket events API is not covered here. See the Events Websockets API documentation.
Authentication¶
Most endpoints require a Bearer token. Obtain one by sending a POST request to
/api/login with your credentials as form data.
To quickly retrieve a token from the command line:
Authorizing in Swagger UI¶
- Open
http://localhost:9999/docs. - Click the Authorize button (top right).
- Input your
usernameandpasswordin the top 2 form fields. You can ignore theclient_idandclient_secretfields.
All subsequent requests made through the UI will include the token automatically.
Making authorized requests in code¶
The example below uses the requests library to
authenticate and build a session that automatically attaches the token to every request.
authorized_client.py
import requests
USERNAME = "admin" # (1)
PASSWORD = "admin"
BASE_URL = "http://localhost:9999"
def make_authorized_session(username: str, password: str, base_url: str) -> requests.Session:
response = requests.post(
f"{base_url}/api/login",
data={"username": username, "password": password},
)
response.raise_for_status()
token = response.json()["access_token"]
session = requests.Session()
session.headers["Authorization"] = f"Bearer {token}"
return session
def main() -> None:
session = make_authorized_session(USERNAME, PASSWORD, BASE_URL)
agents = session.get(f"{BASE_URL}/api/agents/all").json() # (2)
print(agents)
if __name__ == "__main__":
main()
- By default the server includes an admin account with username
adminand passwordadmin. Change these constants to match your configuration. - Use the same
sessionobject for all subsequent requests — theAuthorizationheader is set once and reused automatically.