-
Notifications
You must be signed in to change notification settings - Fork 0
Home API
Accessor: server.home
Server documentation: https://docs.tak.gov/api/takserver#tag/home-api
Usage: await server.home.is_admin()
Returns True if the configured certificate has admin rights on the server, otherwise False.
Should probably be the first thing to call before anything else to prevent errors. If the certificate does not have admin rights, many API calls will fail with permission errors.
API: GET /Marti/api/util/isAdmin
Returns: bool
Example:
from python_takserver_api import Server
import asyncio
async def main():
srv = Server("takserver.local", "cert.pem", "key.pem")
if await srv.home.is_admin():
print("Certificate has admin privileges")
else:
print("Not an admin certificate — some API calls may fail")
await srv.close()
asyncio.run(main())Usage: await server.home.get_home()
Returns the raw payload of the server's home endpoint. On the reference server this is the URL of the metrics page (/Marti/metrics/index.html); the exact content depends on the server version and configuration.
API: GET /Marti/api/home
Returns: (status_code, response_data)
Example:
status, data = await srv.home.get_home()
print(status, data)Usage: await server.home.get_user_roles()
Returns the list of roles assigned to the configured certificate, e.g. ["ROLE_ADMIN", "ROLE_NON_ADMIN_UI", "ROLE_WEBTAK"]. This is the raw endpoint behind the has_role() helper.
API: GET /Marti/api/util/user/roles
Returns: (status_code, list[str])
Example:
status, roles = await srv.home.get_user_roles()
print(roles)Usage: await server.home.has_role("ROLE_ADMIN")
Returns True if the configured certificate has the given role, otherwise False. Built on get_user_roles() — no separate request logic.
Parameter: role (str) — the exact role name to check, e.g. ROLE_ADMIN.
Returns: bool
Example:
if await srv.home.has_role("ROLE_ADMIN"):
print("This certificate is an admin")Usage: await server.home.server_version()
Returns the TAK server version string (e.g. "5.7-RELEASE-43-HEAD"), or None if the version endpoint does not answer with HTTP 200.
Why this endpoint and not getVer? The spec's home-api getVer (GET /Marti/api/ver) returns HTTP 500 on the reference server (5.7-RELEASE-43-HEAD) and is therefore deliberately not wrapped — we do not implement functions for endpoints that are proven not to work. This helper uses the working GET /Marti/api/version endpoint (version-api tag) instead. If your server implements getVer correctly, the endpoint is easy to add on top of get_home()'s pattern.
API: GET /Marti/api/version
Returns: str | None
Example:
version = await srv.home.server_version()
if version:
print(f"Server is running TAK {version}")-
getVer(GET /Marti/api/ver): returns HTTP 500 on the reference server (5.7-RELEASE-43-HEAD) — no wrapper is provided. Useserver_version()instead.