Pyground 🐍
INFO

Steam server statistics

Apr 25, 2021 • JBen

Open In Colab

This notebook uses the Master Server Query Protocol and server queries to get a server list and statistics of multiplayer Source and Goldsource engine mods.

  • This is for mods without an AppID and own Steam store page, for those official mods there are https://store.steampowered.com/stats/ and https://steamcharts.com/
  • Python Steam API package documentation: https://steam.readthedocs.io/en/stable/api/steam.game_servers.html
  • Cool standalone server browser: https://github.com/PredatH0r/SteamServerBrowser
In [1]:
# interactively display tables
%load_ext google.colab.data_table

%pip -q install steam
In [2]:
import numpy as np
import pandas as pd
from steam import game_servers as gs
from collections import defaultdict


def get_server_list(*app_ids, has_players=True, limit=500):
    servers = []

    for id in app_ids:
        query_string = ""
        query_string += fr"\appid\{id}"
        query_string += fr"\empty\1" if has_players else ""
        sub = list(gs.query_master(query_string, max_servers=limit))
        servers += sub

        print(f"{len(sub)} servers from query: \"{query_string}\"")
        if len(sub) == limit:
            print(f"Warning, query response limit({limit}) reached, the "
                  f"result is possibly truncated, increase the limit")

    print(f"{len(servers)} servers total")

    return servers


def get_server_info(*servers, apps=None):
    infos = []
    for server in servers:
        try:
            info = gs.a2s_info(server)

            info["address"] = ":".join(map(str, server))

            if "app_id" in info:
                info["app"] = (apps[info["app_id"]] if apps is not None
                               else info["app_id"])
            else:
                info["app"] = "unknown"


            infos.append(info)

        except Exception as e:
            print(f"""{info["address"]}: {type(e).__name__}: {e}""")

    return (pd.DataFrame(infos)
            .set_index(["app", "folder"])
            .sort_values(by="players", ascending=False))


def display_player_count(info):
    display(
        info
        .groupby(info.index)
        .agg(players=pd.NamedAgg(column="players", aggfunc="sum"),
             populated_servers=pd.NamedAgg(column="players", aggfunc="count"),
             mean_players_per_server=pd.NamedAgg(column="players",
                                                 aggfunc="mean"),
             game_names=pd.NamedAgg(column="game", aggfunc=",".join))
        .sort_values(by="populated_servers", ascending=False)
    )


def display_server_info(info):
    c = ["address", "name", "app_id", "app", "game_id", "game", "folder",
         "map", "players", "max_players", "bots", "_type", "protocol",
         "server_type", "environment", "vac", "version", "keywords",
         "sourcetv_port", "sourcetv_name"]

    display(info.reset_index().loc[:, c])
In [3]:
# Goldsource mods without a Steam page usually use Half-Life as the base game,
# Source mods use their respective Source SDK Bases
apps = {
    70: "Half-Life",
    215: "Source SDK Base 2006",
    218: "Source SDK Base 2007",
    243750: "Source SDK Base 2013 Multiplayer",
}
In [4]:
servers = get_server_list(*apps.keys())
info = get_server_info(*servers, apps=apps)
52 servers from query: "\appid\70\empty\1"
9 servers from query: "\appid\215\empty\1"
1 servers from query: "\appid\218\empty\1"
9 servers from query: "\appid\243750\empty\1"
71 servers total
192.169.88.50:29035: timeout: timed out
192.169.88.50:29035: RuntimeError: Invalid reponse header - b'D'
18.156.63.218:27015: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: OSError: [Errno 113] No route to host
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
78.46.191.68:27016: timeout: timed out
185.86.78.191:27015: timeout: timed out
185.86.78.191:27015: RuntimeError: Invalid reponse header - b'D'
31.131.249.69:27018: RuntimeError: Invalid reponse header - b'D'
89.223.32.156:27010: RuntimeError: Invalid reponse header - b'D'
185.171.25.194:27015: timeout: timed out
5.53.16.212:27015: timeout: timed out
45.235.98.40:27042: timeout: timed out
37.201.231.181:10894: timeout: timed out
37.201.231.181:10894: timeout: timed out
78.47.20.213:27019: timeout: timed out
78.47.20.213:27019: timeout: timed out
78.47.20.213:27019: timeout: timed out
78.47.20.213:27019: timeout: timed out
78.47.20.213:27019: timeout: timed out
In [5]:
display_player_count(info)
display_server_info(info)
players populated_servers mean_players_per_server game_names
(Half-Life, valve) 143 22 6.500000 Sev+|GG EDITION,D A W N,H λ L F - L I F E,H...
(Half-Life, ag) 13 6 2.166667 HLCCL,AG FFA,AG TDM,HLCCL,AGT,AG TDM
(Source SDK Base 2006, hidden) 4 4 1.000000 Hidden : Source B4,Hidden : Source B4,Hidden :...
(Source SDK Base 2013 Multiplayer, tf2classic) 32 4 8.000000 Team Fortress 2 Classic,Deathrun Toolkit | 0.4...
(Source SDK Base 2006, gmod9) 6 2 3.000000 GMod 9.0.4,GMod 9.0.4
(Half-Life, dpbredux) 3 1 3.000000 Digital Paintball
(Half-Life, nnk) 1 1 1.000000 Naruto Naiteki Kensei R1
(Source SDK Base 2006, zombie_master) 2 1 2.000000 Zombie Master 1.2.1
(Source SDK Base 2007, gesource) 3 1 3.000000 Team Arsenal (MOD)
address name app_id app game_id game folder map players max_players bots _type protocol server_type environment vac version keywords sourcetv_port sourcetv_name
0 54.39.130.18:27015 VaultF4.com - Official [US] Standard 243750 Source SDK Base 2013 Multiplayer 243750.0 Team Fortress 2 Classic tf2classic cp_coldfront 14 30 0 source 17 d l 1 5394425 HLstatsX:CE,alltalk,cp,increased_maxplayers,no... 27020.0 SourceTV Test
1 23.124.59.250:27015 Gamers-Global.com|HLSTATS|SEV+|FASTDL|CUSTOM|1... 70 Half-Life 70.0 Sev+|GG EDITION valve 7th_path 14 22 4 source 48 d w 1 1.1.2.2 NaN NaN
2 84.22.153.100:27018 Dawn HL Crossfire Only 70 Half-Life 70.0 D A W N valve crossfire 14 20 3 source 48 d w 1 1.1.2.2/Stdio NaN NaN NaN
3 188.213.212.5:27015 |-> -==[24/7]==- HL.Pyro-Zone.com <-| 70 Half-Life 70.0 H λ L F - L I F E valve hl_assault 13 32 2 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
4 62.140.250.10:27015 ! !--Good_Half-Life_Server--! ! 70 Half-Life 70.0 Half-Life valve crossfire 13 32 1 source 48 d w 1 1.1.2.2/Stdio NaN NaN NaN
5 78.152.169.100:27016 [VICTORY.KM.UA] Half-Life DM FFA 70 Half-Life NaN Half-Life valve closefire 13 32 0 source 48 d w 0 1.1.2.7/Stdio NaN NaN NaN
6 192.223.30.68:27015 ! !--Best_Half-Life_Server--! ! 70 Half-Life 70.0 H λ L F - L I F E valve crossfire 10 10 0 source 48 d w 1 1.1.2.2/Stdio NaN NaN NaN
7 84.22.153.100:27015 Dawn Half-Life 70 Half-Life 70.0 D A W N valve dead-dust2 9 20 2 source 48 d w 1 1.1.2.2/Stdio NaN NaN NaN
8 78.47.20.213:27019 ⬛█ Death Ventures | Combat / Jailbreak / Death... 243750 Source SDK Base 2013 Multiplayer 243750.0 Deathrun Toolkit | 0.4.1 tf2classic dr_bank_v12a 9 24 0 source 17 d l 1 5394425 deathrun,deathventures,jailbreak,teamfortress2... NaN NaN
9 192.169.88.50:29035 *L.T.K*Clan Server 1 70 Half-Life 70.0 Severian's Mod valve dutch_wonderfire 7 26 3 source 48 d w 1 1.1.2.2 NaN NaN NaN
10 51.195.91.179:27016 VaultF4.com - Official [EU] Randomizer 243750 Source SDK Base 2013 Multiplayer 243750.0 Team Fortress 2 Classic tf2classic plr_hightower 6 24 0 source 17 d l 1 5394425 HLstatsX:CE 27021.0 SourceTV Test
11 185.86.78.191:27015 -=-=- hldm-ARENA.cf:27015 crossfire -=-=- 70 Half-Life 70.0 Half-Life valve crossfire 6 24 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
12 85.14.226.179:27015 Xen-Raiders AG 2016 by ngz-server.de 70 Half-Life 70.0 HLCCL ag crossfire 5 18 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
13 46.0.203.113:27015 K_P_A_C_A_B_A C_E_P_B_E_P 70 Half-Life 70.0 [ Music Server ] valve dk_katklub 5 18 0 source 48 d w 0 1.6.3.7/Stdio NaN NaN NaN
14 145.239.108.67:27015 *L.T.K*Clan Server 3 70 Half-Life 70.0 Severian's Mod valve tig_nite 5 26 3 source 48 d w 1 1.1.2.2 NaN NaN NaN
15 139.162.49.132:27015 ! !--Asia_Half-Life_Server--! ! 70 Half-Life NaN H A L F - L I F E valve the_yard2 5 12 2 source 48 d l 1 1.1.2.7/Stdio NaN NaN NaN
16 31.131.249.69:27018 GunGame 2.2 - HLDM.ORG 70 Half-Life NaN Half-Life valve ps2waypoint 5 32 3 source 48 d l 1 1.1.2.7/Stdio NaN NaN NaN
17 5.53.16.212:27015 [hlserv] DM + weaponmod 70 Half-Life NaN Severian's Mod+ valve crossfire 5 16 1 source 48 d l 1 1.1.2.7/Stdio NaN NaN NaN
18 192.145.47.121:27017 nafrayus server 215 Source SDK Base 2006 NaN GMod 9.0.4 gmod9 gm_construct 4 16 0 source 7 d w 0 1.0.1.0 NaN NaN NaN
19 5.53.16.212:27017 [hlserv] Crossfire 24\7 70 Half-Life NaN Severian's Mod+ valve crossfire 4 24 0 source 48 d l 1 1.1.2.7/Stdio NaN NaN NaN
20 89.223.32.156:27010 AIMaster HL DM 1 | Newbies ONLY 70 Half-Life NaN Half-Life valve crossfire 4 20 0 source 48 d w 1 1.1.2.7/Stdio NaN NaN NaN
21 94.23.247.37:27040 HL2GO.COM - HLDM [EU] 70 Half-Life NaN Half-Life valve dust2x2 3 32 0 source 48 d l 1 1.1.2.7/Stdio NaN NaN NaN
22 104.238.180.59:27065 Official DPB Redux Field | USA | West 70 Half-Life 70.0 Digital Paintball dpbredux NXL_TexasOpen_2018 3 20 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
23 89.216.18.137:27025 CobraNetwork: AGmod | FFA | Crossfire 70 Half-Life 70.0 AG FFA ag crossfire 3 10 0 source 48 d w 1 1.1.2.2 NaN NaN
24 85.117.240.15:27025  ► BlackWonder US TF2C | Hightower | No Car... 243750 Source SDK Base 2013 Multiplayer 243750.0  ► Hightower ◄ tf2classic plr_hightower 3 64 0 source 17 d l 1 5394425 increased_maxplayers,_registered,afk,alltalk,b... NaN NaN
25 74.91.114.38:27015 Noob's Wonderland 218 Source SDK Base 2007 218.0 Team Arsenal (MOD) gesource ge_facility_classic 3 22 0 source 17 d w 1 1.0.1.0 HLstatsX:CE,alltalk,autoteamplay,increased_max... NaN NaN
26 45.155.125.20:27025 SADECE PIMPLER 70 Half-Life 70.0 Half-Life valve crossfire 2 16 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN
27 172.107.174.142:27015 -=OAK=- Dallas, Texas 70 Half-Life 70.0 Severian's Mod valve Boot2 2 16 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
28 78.46.191.68:27016 AGHLDM DE #2 | 1000 FPS | FastDL 70 Half-Life 70.0 AG TDM ag stalkx 2 32 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
29 45.235.98.40:27042 ||LegenDary Team :-) 70 Half-Life 70.0 www.4evergaming.com.ar valve stalkx 2 12 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
30 37.201.231.181:10894 LEMCraft der pro 215 Source SDK Base 2006 NaN GMod 9.0.4 gmod9 gm_construct 2 16 0 source 7 l w 1 1.0.1.0 NaN NaN NaN
31 149.28.44.79:27017 -DTR- Almost Vanilla ZM Server (+RTD,RTV) 215 Source SDK Base 2006 NaN Zombie Master 1.2.1 zombie_master zm_zombiefacility_v2 2 16 1 source 7 d w 0 1.0.1.0 NaN NaN NaN
32 18.156.63.218:27015 NPN Half-Life Server 70 Half-Life 70.0 Half-Life valve crossfire 1 20 0 source 48 d w 1 1.1.2.2 NaN NaN NaN
33 185.107.96.114:27015 SiDiouS Phys Server FF-Off PS-Off 215 Source SDK Base 2006 215.0 Hidden : Source B4 hidden hdn_barrel_warz_v1 1 9 1 source 7 d w 0 1.0.1.0 NaN NaN NaN
34 74.91.124.33:27015 The Living Dead - Hidden Source Server pshove/... 215 Source SDK Base 2006 215.0 Hidden : Source B4 hidden hdn_demise 1 9 1 source 7 d w 0 1.0.1.0 NaN NaN NaN
35 162.248.93.98:27015 Stabbiη Cabiη ♢ Ranked ♢ PS:Shove|FF:Reflect 215 Source SDK Base 2006 215.0 Hidden : Source B4 hidden hdn_physics_arena_final 1 9 1 source 7 d w 0 1.0.1.0 NaN NaN NaN
36 173.24.229.150:27015 Playground~Genuine~Gaming~HL~Linux 70 Half-Life 70.0 Half-Life valve atticrats_ro 1 15 0 source 48 d l 0 1.1.2.2/Stdio NaN NaN NaN
37 74.91.113.158:27015 OL'Farts Gaming www.olfartsgaming.com 215 Source SDK Base 2006 215.0 Hidden : Source B4 hidden hdn_docks 1 9 1 source 7 d w 0 1.0.1.0 NaN NaN NaN
38 95.216.140.175:27015 {Helsinki} DM Server by [Z] Chuck Moris 70 Half-Life 70.0 Naruto Naiteki Kensei R1 nnk nnk_preliminary 1 25 0 source 48 d w 1 1.1.2.7/Stdio NaN NaN NaN
39 112.213.38.144:27020 AG Australia [1000fps] 70 Half-Life 70.0 HLCCL ag no_remorse 1 10 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN
40 185.171.25.194:27015 [AGT] AGTurkiye Turnuva Sunucusu* |TR| #2 70 Half-Life 70.0 AGT ag datacore 1 32 0 source 48 d l 1 1.1.2.2/Stdio NaN NaN NaN
41 109.184.60.233:27015 www.planethalflife.com/agmod 70 Half-Life 70.0 AG TDM ag ag_crossfire 1 32 0 source 48 l w 0 1.1.2.2/Stdio NaN NaN
  • JBen