The OpenGSQ Python library provides a convenient way to query servers from applications written in the Python language.
The library supports a wide range of protocols. Here are some examples:
from opengsq.protocols import (
    ASE,
    Battlefield,
    Doom3,
    ElDewrito,
    EOS,
    FiveM,
    Flatout2,
    GameSpy1,
    GameSpy2,
    GameSpy3,
    GameSpy4,
    Kaillera,
    KillingFloor,
    Minecraft,
    Nadeo,
    Palworld,
    Quake1,
    Quake2,
    Quake3,
    RakNet,
    RenegadeX,
    Samp,
    Satisfactory,
    Scum,
    Source,
    TeamSpeak3,
    Toxikk,
    UDK,
    Unreal2,
    UT3,
    Vcmp,
    WON,
)- Python 3.7 or higher
The recommended installation method is using pip:
pip install --upgrade opengsqHere’s an example of how to query a server using the Source protocol:
import asyncio
from opengsq.protocols import Source
async def main():
    source = Source(host='45.147.5.5', port=27015)
    info = await source.get_info()
    print(info)
asyncio.run(main())You can also use the Source Remote Console:
import asyncio
from opengsq.exceptions import AuthenticationException
from opengsq.rcon_protocols.source_rcon import SourceRcon
async def main():
    with SourceRcon("123.123.123.123", 27015) as source_rcon:
        try:
            await source_rcon.authenticate("serverRconPassword")
        except AuthenticationException:
            print('Failed to authenticate')
        response = await source_rcon.send_command("cvarlist")
        print(response)
asyncio.run(main())This library additionally provides an opengsq command-line utility
which makes it easy to query game servers from your terminal. Run
opengsq -h for usage.
# query server using source protocol
opengsq source --host 123.123.123.123 --port 27015 --function get_infoYou can find information about tests and results at https://python.opengsq.com/tests/protocols
Contributions are welcome! Please feel free to submit pull requests or open issues.