Skip to content

Getting Started

sgofferj edited this page Aug 26, 2026 · 4 revisions

Getting Started

Installation

From source

git clone https://github.com/sgofferj/python-takserver-api
cd python-takserver-api
poetry install

Via pip

pip install python-takserver-api

Requirements

Dependency Version Use
Python >= 3.11 Runtime
aiohttp any Async HTTP client
libadvian >= 1.7 Logging, utilities
click >= 8.1 CLI entrypoint

Configuration

Server connection

Create a Server instance with three arguments:

from python_takserver_api import Server

srv = Server(
    host="takserver.example.com",   # TAK server hostname or IP
    cert="/path/to/client.pem",     # PEM-encoded client certificate
    key="/path/to/client-key.pem",  # PEM-encoded private key
)

The library connects to port 8443 (default TAK API port). SSL hostname verification is disabled; the client certificate is used for mutual TLS authentication.

TLS notes

  • Certificate and key must be in PEM format
  • The server CA does not need to be trusted (hostname verification is off)
  • For testing, self-signed certificates work

Warning

By default the server certificate is not verified at all (CERT_NONE): the client authenticates itself with its certificate, but nothing checks the identity of the server it talks to. This is a deliberate trade-off because TAK Servers typically run self-signed certificates - but it means an attacker who can intercept your connection could impersonate the server. Do not point this library at hosts you do not trust.

Verifying the server (optional)

Pass ca_cert to pin a CA (or the server's self-signed certificate itself) and get full server verification including hostname checking:

srv = Server(
    host="takserver.local",
    cert="/path/to/client-cert.pem",
    key="/path/to/client-key.pem",
    ca_cert="/path/to/ca-or-server-cert.pem",  # verify the server
)

The certificate presented by the server must chain to ca_cert and its CN/SAN must match the host you connect to. The client certificate for mutual TLS is always sent, in both modes.

Basic usage

Check admin status

if await srv.home.is_admin():
    print("Certificate has admin privileges")

List users

status, data = await srv.user.get_all_users()
if status == 200:
    for user in data:
        print(user["username"])

Create a user

# IN = groups the user may send into, OUT = groups they receive from
status, data = await srv.user.create_or_update_file_user(
    username="operator1",
    password="s3cr3t",
    group_list_out=["default"],
)

Work with missions

# Create a mission
status, data = await srv.mission.create_mission(
    name="op-recon",
    creator_uid="DRONE-001",
    group="recon-team",
)

# Get mission details
status, data = await srv.mission.get_mission("op-recon")

# Subscribe to a mission
status, data = await srv.mission.create_mission_subscription(
    name="op-recon",
    uid="DRONE-001",
)

# Add content
status, data = await srv.mission.add_mission_content(
    name="op-recon",
    uids=["cot-msg-001", "cot-msg-002"],
    my_uid="DRONE-001",
    token="<bearer-token>",
)

Cleanup

Always close the HTTP session when done:

await srv.close()

Development

Setup

poetry install
pre-commit install --install-hooks

Tests

poetry run pytest -v

Code quality

The pre-commit config runs black, mypy (strict), pylint, bandit, and detect-secrets on every commit.

Clone this wiki locally