Skip to main content

A2SQuery A2SQuery Documentation Status

A2SQuery is a Python implementation of Valve's A2S protocol.

View a demo application.

Docs

View the full A2SQuery documentation here.

Features

  • Sync and Async Implementations - Includes fully featured synchronous and asyncio-driven networking engines with API parity.
  • Comprehensive API Coverage - Full protocol implementation spanning the modern Source API and obsolete Source and GoldSource legacy versions.
    • Multi-packet batch assembly for split responses across engines.
    • Supports BZIP2 compressed responses.
    • Handles MTU edge cases for early Source games.
    • Catches and discards malformed or unwanted/extra packets.
  • Network Fault Tolerance - Resilient network I/O.
    • Exponential back-off retrying of failed or invalid requests.
    • Per-request socket buffer flushing to eliminate cross-request race conditions and overflow.
    • Enforces limits on challenge handshakes to prevent infinite handshake loops.
    • Saves challenge tokens for faster successive requests.
  • Strict Typing (PEP 561) - Fully type hinted with dataclass response structures.
  • Standard Library Only - Zero dependencies.

Prerequisites

  • Python >= 3.7

Installation

Install the library via PyPi with

pip install a2squery

Examples

More examples available on the docs.

Synchronous

When using a2squery.A2SQuery without a context manager, remember to call a2squery.A2SQuery.close() when finished to close the socket.

from a2squery import A2SQuery

with A2SQuery("127.0.0.1", 27015) as a2s:
    print(a2s.info())
    # print(a2s.rules())
    # print(a2s.players())

    # SourceInfo(
    #     protocol=17, name="Awp Bhop", map="awp_iceworld",
    #     folder="csgo", game="Counter-Strike: Global Offensive",
    #     app_id=730, players=43, max_players=64, bots=0,
    #     server_type=ServerType.Dedicated, environment=Environment.Linux,
    #     password=False, vac=True, version="1.38.4.4", extra_data_flag=177,
    #     mode=None, witnesses=None, duration=None,
    #     port=27015, steam_id=85568392924437989, spectator_port=None,
    #     spectator_name=None, keywords="awp,bhop,a2squeryiscool", game_id=730
    # )

Asynchronous

When using a2squery.AsyncA2SQuery without a context manager, you will need to call a2squery.AsyncA2SQuery.connect() to start the connection. Remember to call a2squery.A2SQuery.close() when finished to close the socket.

from a2squery import AsyncA2SQuery

async with A2SQuery("127.0.0.1", 27015) as a2s:
    print(await a2s.info())
    # print(await a2s.rules())
    # print(await a2s.players())

    # SourceInfo(
    #     protocol=17, name="Awp Bhop", map="awp_iceworld",
    #     folder="csgo", game="Counter-Strike: Global Offensive",
    #     app_id=730, players=43, max_players=64, bots=0,
    #     server_type=ServerType.Dedicated, environment=Environment.Linux,
    #     password=False, vac=True, version="1.38.4.4", extra_data_flag=177,
    #     mode=None, witnesses=None, duration=None,
    #     port=27015, steam_id=85568392924437989, spectator_port=None,
    #     spectator_name=None, keywords="awp,bhop,a2squeryiscool", game_id=730
    # )

Supported Games (Non-Exhaustive)

App ID Game Notes
... All Half-Life/Half-Life 2 mods and games
10 Counter-Strike 1.6
440 Team Fortress 2
550 Left For Dead 2
730 Counter-Strike: Global Offensive
1002 Rag Doll Kung Fu
2400 The Ship: Murder Party This game has various unique fields on a2squery.SourceInfo and a2squery.Player.
4000 Garry's Mod
17710 Nuclear Dawn
70000 Dino D-Day
107410 Arma 3 The query port is the server port + 1.
115300 Call of Duty: Modern Warfare 3
211820 Starbound
244850 Space Engineers The query port is the server port + 1.
304930 Unturned The query port is the server port + 1.
251570 7 Days To Die
252490 Rust
282440 Quake Live
346110 ARK: Survival Evolved
108600 Project: Zomboid

Metadata

Release files for a2squery 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2squery 1.2.1
File Size Uploaded
a2squery-1.2.1.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2squery 1.2.1
File Interpreter ABI Platform
a2squery-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.1 kB

Release files / a2squery-1.2.1.tar.gz

Download URL a2squery-1.2.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7bbd382a612d296aaf676c7a85dfa3bae5e79d1927a5d9745f92ee6baf5d8cae
BLAKE2b-256 checksum
How to use checksums
65a9b46fcedfe87ee3c06cd83eff092fed2881a8a858ef8ef9cc12675b1e8ce8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / a2squery-1.2.1-py3-none-any.whl

Download URL a2squery-1.2.1-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20e63c2bedb74838328cf92e17ebea53723f0b122dda91ac8c181329290b4102
BLAKE2b-256 checksum
How to use checksums
b0a02c79a8612392573a5d14bf2fa140de8b9fbfa82b910496330fb8ecbaffcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.2

2 release files

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page