ts3-web-query
Async Python wrapper for the TeamSpeak 3 HTTP WebQuery API (not the raw telnet/SSH
ServerQuery). Built on aiohttp; commands return typed dataclasses.
Status: alpha. All ServerQuery commands accepted by WebQuery are covered (109 of the 130 documented ones); see Not supported.
Requirements
- Python 3.10+
aiohttp >= 3.9- A TeamSpeak 3 server with WebQuery enabled and an API key (
apikeyadd)
Installation
pip install ts3-web-query
Quick start
import asyncio
from ts3_web_query import Client
async def main():
async with Client(
api_url="http://127.0.0.1:10080", # WebQuery address
api_key="BABAB...", # x-api-key
instance_id=1, # virtual server (sid)
timeout=30.0, # total request timeout, seconds
) as client:
print(await client.server.server_info())
print(await client.channel.channel_list())
asyncio.run(main())
Without async with, close the HTTP session yourself: await client.close().
A complete example is in examples/basic_usage.py.
Types and IDE hints
from ts3_web_query import Client, TeamSpeakError
from ts3_web_query.constants import TargetMode
from ts3_web_query.properties import ChannelCreateProperties
from ts3_web_query.types import ServerInfo
props: ChannelCreateProperties = {"channel_name": "Lobby", "channel_flag_permanent": 1}
cid = await client.channel.channel_create(props) # int | TeamSpeakError
info = await client.server.server_info()
if not isinstance(info, TeamSpeakError): # narrows the type: fields are suggested
print(info.virtualserver_name)
Create/edit properties are TypedDicts, so editors and mypy check the keys. The package ships py.typed.
Error handling
- Network failures and unexpected responses raise
ts3_web_query.TeamSpeakConnectionError. - TeamSpeak errors are not raised: the method returns
TeamSpeakError(code, message, extra_message). Commands without a payload returnTeamSpeakError(code=0, message='ok')on success.
result = await client.channel.channel_delete(cid=5, force=True)
if result.code != 0:
print("failed:", result.message)
An empty result is reported by the server as error 1281 (database empty result set),
so e.g. ban_list() with no bans returns TeamSpeakError(code=1281, ...), not an empty list.
Implemented API
| Area | Client attribute |
Methods |
|---|---|---|
| Server / instance | client.server |
server_list, server_info, server_id_get_by_port, server_create, server_edit, server_delete, server_start, server_stop, server_process_stop, server_request_connection_info, server_temp_password_add/del/list, host_info, whoami, version, instance_info, instance_edit, log_view, log_add, global_message, server_snapshot_create, server_snapshot_deploy |
| Channels | client.channel |
channel_list, channel_info, channel_find, channel_create, channel_edit, channel_move, channel_delete, channel_perm_list, channel_add_perm, channel_del_perm, channel_client_perm_list, channel_client_add_perm, channel_client_del_perm |
| Channel groups | client.channel_group |
channel_group_list, channel_group_add, channel_group_del, channel_group_copy, channel_group_rename, channel_group_perm_list, channel_group_add_perm, channel_group_del_perm, channel_group_client_list, set_client_channel_group |
| Server groups | client.server_group |
server_groups_list, server_group_add, server_group_del, server_group_copy, server_group_rename, server_group_perm_list, server_group_add_perm, server_group_del_perm, server_group_add_client, server_group_del_client, server_group_client_list, server_groups_by_client_id, server_group_auto_add_perm, server_group_auto_del_perm |
| Clients | client.clients |
client_list, client_info, client_find, client_edit, client_update, client_move, client_kick, client_poke, client_db_list, client_db_info, client_db_find, client_db_edit, client_db_delete, client_get_ids, client_get_dbid_from_uid, client_get_name_from_uid, client_get_uid_from_clid, client_get_name_from_dbid, client_set_serverquery_login, client_perm_list, client_add_perm, client_del_perm |
| Permissions / tokens | client.permission |
permission_list, perm_id_get_by_name, perm_overview, perm_get, perm_find, perm_reset, privilege_key_list/add/delete/use, custom_search, custom_info |
| Messages, complaints, bans | client.messaging |
send_text_message, send_private_message, message_list/add/del/get/update_flag, complain_list/add/del/del_all, ban_client, ban_list, ban_add, ban_del, ban_del_all |
Methods with repeated parameters (several clids, permission sets, ...) take lists. They are
sent as POST with a JSON body, because WebQuery silently honors only the first value of a
repeated query-string key.
Some operations are destructive: perm_reset resets the virtual server's permissions,
server_snapshot_deploy recreates channels and groups (their IDs change), ban_del_all
removes every ban.
Limitations
server_createis limited by the server license (a second virtual server gives error 2816 without one).client_set_serverquery_logindoes not work over WebQuery: a connection authorized by an API key has no client ID (error 512).- Commands of the whole instance (
serverlist,servercreate,serverdelete,serverstart,serverstop,hostinfo,version, ...) are sent without a virtual server ID in the path; every other command usesinstance_id.
Not supported
- File transfer (
ft*, 9 commands): WebQuery answers5120 out of scopefor any API key. servernotifyregister/servernotifyunregister: unavailable in WebQuery.- Raw-session commands
login,logout,use,quit,help,bindinglist: authentication uses thex-api-keyheader and the server is chosen withinstance_id. - Aliases
tokenadd/tokendelete/tokenlist/tokenuse: useprivilege_key_*.
License
Metadata
Release files for ts3-web-query 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ts3_web_query-0.1.1.tar.gz | 37.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ts3_web_query-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.6 kB
Release files / ts3_web_query-0.1.1.tar.gz
| Download URL | ts3_web_query-0.1.1.tar.gz |
|---|---|
| Size | 37.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6b685255cfa48a18bf2828a54f5a3bab0bdcadfb2b293ba67d923978c358140
|
|
BLAKE2b-256 checksum How to use checksums |
9eb9f9caa6b10a8a4316e501b64d9bbcf9c9c63ad7c879e36b8fe78eedc6bfc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / ts3_web_query-0.1.1-py3-none-any.whl
| Download URL | ts3_web_query-0.1.1-py3-none-any.whl |
|---|---|
| Size | 36.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe83a069a0800a50f7c16cf03b8803ad96d582569c653fb6daaa17a3eb1cfd59
|
|
BLAKE2b-256 checksum How to use checksums |
8021fd10e5a2d969852c3c0d8cf3732e730a2b211bff1b167a1a74461b23f989
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|