OpenGSQ Documentation

website·Indexed 29 days ago

https://python.opengsq.com/

A Python library for querying game servers. It provides a wide range of response packages for various game protocols, including Minecraft, Palworld, Source, Battlefield, SCUM, and others, allowing developers to retrieve server details such as player counts, versions, and server names.

Tokens
52.2K
Snippets
283
Records
316
Agent score
49%

What's inside OpenGSQ

  1. Use the Info class to represent Battlefield game server data

    The opengsq.responses.battlefield.Info class represents detailed information about a Battlefield game server. It contains both required and optional properties describing the server's state, configuration, and location.
    from opengsq.responses.battlefield import Info
    
    # Example of the properties available in the Info class:
    # Required:
    # - hostname_ (str): Server hostname
    # - num_players_ (int): Current player count
    # - max_players_ (int): Maximum player capacity
    # - game_type_ (str): Type of game
    # - map_ (str): Current map
    # - rounds_played_ (int): Rounds played
    # - rounds_total_ (int): Total rounds
    # - teams_ (list[float]): List of teams
    # - target_score_ (int): Target score
    # - status_ (str): Game status
    # - ranked_ (bool): Ranked status
    # - punk_buster_ (bool): PunkBuster enabled
    # - password_ (bool): Password required
    # - uptime_ (int): Server uptime
    # - round_time_ (int): Round time
    
    # Optional:
    # - mod_ (str | None): Game mod
    # - ip_port_ (str | None): IP port
    # - punk_buster_version_ (str | None): PunkBuster version
    # - join_queue_ (bool | None): Join queue enabled
    # - region_ (str | None): Server region
    # - ping_site_ (str | None): Ping site
    # - country_ (str | None): Server country
    # - blaze_player_count_ (int | None): Blaze player count
    # - blaze_game_state_ (str | None): Blaze game state
    # - quick_match_ (bool | None): Quick match enabled
  2. Understand the SCUM master server query response format

    When querying the SCUM master server using the test_query_master_servers method, the system returns a list of server objects. Each object contains technical details about the game server, including its network address, player capacity, and versioning.
    {
        "ip": "213.239.195.22",
        "port": 7002,
        "name": "[GER] Adventure-Island - TEST & EVENT SERVER",
        "num_players": 0,
        "max_players": 80,
        "time": 20,
        "password": true,
        "version": "0.9.515.81588"
    }
  3. Access Battlefield game server information via opengsq.responses.battlefield.Info

    The opengsq.responses.battlefield.Info class provides metadata about a Battlefield game server. Available attributes include:

    • teams_ (list[float]): The list of teams.
    • target_score_ (int): The target score for the game.
    • status_ (str): The current status of the game.
    • ranked_ (bool): Indicates if the game is ranked.
    • punk_buster_ (bool): Indicates if PunkBuster is enabled.
    • password_ (bool): Indicates if a password is required to join.
    • uptime_ (int): The server uptime.
    • round_time_ (int): The duration of the round.
  4. Access server information using opengsq.responses.trackmania_nations.ServerInfo

    The ServerInfo class in the opengsq.responses.trackmania_nations.server_info module provides details about a Trackmania Nations server's current state. It includes the following attributes:

    • map_ (str): The name of the current map being played.
    • players_ (int): The current number of players connected to the server.
    • max_players_ (int): The maximum player capacity of the server.
    • game_mode_ (str): The current game mode (e.g., 'Time Attack', 'Rounds', 'Cup').
  5. Understand the SCUM master server query response format

    When querying the SCUM master servers using the test_query_master_servers method, the API returns a list of server objects. Each object contains technical details about the game server, including its network address, capacity, and current version.
    [
        {
            "ip": "195.82.158.17",
            "port": 7939,
            "name": "Geckos PVE Server",
            "num_players": 0,
            "max_players": 8,
            "time": 23,
            "password": true,
            "version": "0.9.515.81588"
        }
    ]
  6. Represent Supreme Commander server status with the Status class

    The opengsq.responses.supcom.status.Status class represents the status of a Supreme Commander game server. It contains detailed information about the game lobby, the host, the map, and specific game rules.
    from opengsq.responses.supcom.status import Status
    
    # Example of the data structure represented by Status
    # Status(_game_name, _hosted_by, _product_code, _scenario_file, _num_players, ...)
  7. Use the opengsq.responses.toxikk.Status class for Toxikk server responses

    The opengsq.responses.toxikk.Status class represents a Toxikk-specific server status response. It inherits from opengsq.responses.udk.status.Status and adds support for mutators. It contains detailed information about the server state, including player counts, map, game type, and security settings.
    from opengsq.responses.toxikk import Status
    
    # Example of the Status class structure
    status = Status(
        name="Server Name",
        map="MapName",
        game_type="GameType",
        num_players=5,
        max_players=20,
        password_protected=False,
        stats_enabled=True,
        lan_mode=False,
        players=[...], # List of opengsq.responses.udk.status.Player
        raw={...},     # Raw response dictionary
        mutators=["Mutator1", "Mutator2"]
    )
  8. Use the Status class to access Jedi Knight server details

    The Status class in opengsq.responses.jediknight.status provides detailed information about a Jedi Knight server's current state, including server configuration, limits, and the current player list.
    # Attributes available in the Status class:
    status.gamename      # Game name (e.g., 'basejka' for base game)
    status.mapname       # Current map name
    status.protocol      # Protocol version
    status.sv_allowDownload # Allow downloads status
    status.sv_floodProtect  # Flood protection status
    status.sv_hostname    # Server hostname
    status.sv_maxPing     # Maximum ping
    status.sv_maxRate     # Maximum rate
    status.sv_maxclients  # Maximum clients
    status.sv_minPing     # Minimum ping
    status.sv_privateClients # Private clients
    status.timelimit     # Time limit
    status.version      # Server version
    status.players       # List of Player objects currently on the server
  9. Access game session status and configuration via opengsq.responses.supcom.Status

    The opengsq.responses.supcom.Status object provides detailed information about a game session's configuration, map properties, and current state. It includes raw data and processed properties for human-readable output.
    # Example properties available on a Status object:
    status.game_name          # Name of the game
    status.hosted_by           # Host identifier
    status.product_code        # Product code of the game
    status.num_players         # Current number of players
    status.unit_cap            # Unit limit (e.g., '500')
    status.victory_condition   # Victory condition (e.g., 'demoralization')
    status.game_speed          # Game speed (e.g., 'normal')
    status.raw                 # Dictionary of raw response data
    status.options             # Dictionary of game options
  10. Understand the SCUM master server query response format

    When querying the SCUM master servers via the test_query_master_servers method, the system returns a list of server objects. Each object contains technical metadata about the game server, including its network address, player capacity, and current version.
    {
        "ip": "176.57.181.176",
        "port": 28802,
        "name": "Valhalla PVE ",
        "num_players": 1,
        "max_players": 20,
        "time": 12,
        "password": false,
        "version": "0.9.515.81588"
    }
  11. Represent UDK players with the Player class

    The Player class in opengsq.responses.udk.status stores information about an individual player connected to a UDK server.
    from opengsq.responses.udk.status import Player
    
    # Player attributes:
    # player.name_ (str): Player's name
    # player.score_ (int): Player's current score (default 0)
    # player.ping_ (int): Player's latency/ping (default 0)
    # player.team_ (int): Player's team ID (default 0)
  12. Understand SCUM master server query response format

    When querying SCUM master servers, the response returns a list of server objects. Each object contains technical metadata about the game server, including its network address, player capacity, security settings, and software version.
    {
        "ip": "176.57.178.93",
        "port": 28702,
        "name": "SCUM Embers",
        "num_players": 0,
        "max_players": 10,
        "time": 24,
        "password": true,
        "version": "0.9.515.81588"
    }