Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

pygsi is a Python library to interface with CS2’s Game State Integration.

Game State Integration (GSI) is built into Counter-Strike 2. You give CS2 a config file with a URL, and while you play, it sends that URL HTTP POST requests with JSON about the current map, round, and player. pygsi runs the server that receives them. It parses each payload into typed Pydantic models, keeps the latest state for each player it tracks, and compares each payload with the one before to work out what happened, such as a round starting, the bomb going down, or a kill. Then it calls the async handlers you’ve registered for those events.

pygsi is for players, not spectators or observers. CS2 sends observers much more, such as every player’s position and who carries the bomb, but none of it reaches a player’s own client, so pygsi only models what a player’s client sends. You can see what’s missing in Limitations. For the protocol itself, with every field CS2 sends, see the draft CS2 GSI spec.

Who This Book Is For

This book is for Python developers who want their code to react to CS2 games. We assume you’re comfortable with async def and await, but you don’t need to know anything about GSI. Start with Installation and CS2 Setup and the Quick Start, and then read the other chapters in whatever order you need them.

Installation and CS2 Setup

Installing pygsi

You’ll need Python 3.11 or newer. On PyPI the package is called pygsi-cs2, because the name pygsi was already taken, but you import it as pygsi:

pip install pygsi-cs2
# or
uv add pygsi-cs2

The Config File

CS2 looks for GSI config files in its cfg folder when it starts. Any file whose name starts with gamestate_integration_ and ends with .cfg counts. Create one called gamestate_integration_pygsi.cfg in the game/csgo/cfg/ folder of your CS2 install:

OSFolder
WindowsC:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo\cfg\
macOS~/Library/Application Support/Steam/steamapps/common/Counter-Strike Global Offensive/game/csgo/cfg/
Linux~/.steam/steam/steamapps/common/Counter-Strike Global Offensive/game/csgo/cfg/

Warning

CS:GO kept these files in csgo/cfg/, and CS2 doesn’t read that folder anymore. If you installed CS2 in another Steam library folder, look under that folder’s steamapps/common/ instead.

Here’s what goes in the file:

"pygsi"
{
  "uri"       "http://127.0.0.1:4213"
  "timeout"   "5.0"
  "buffer"    "1.0"
  "throttle"  "1.0"
  "heartbeat" "30.0"

  "data"
  {
    "provider"            "1"
    "player_id"           "1"
    "player_state"        "1"
    "player_match_stats"  "1"
    "map"                 "1"
    "map_round_wins"      "1"
    "round"               "1"
  }
}

The uri is where CS2 sends its payloads. Port 4213 is pygsi’s default, and 127.0.0.1 means the server runs on the same machine as the game. If it runs somewhere else, put that machine’s address here.

The four timing settings control how often CS2 sends updates, and they’re all in seconds:

SettingMeaning
timeoutHow long CS2 waits for the server to respond.
bufferHow long CS2 collects changes before it sends them in one payload.
throttleThe shortest time between two payloads.
heartbeatThe longest time between two payloads, even when nothing changes.

Lower buffer and throttle if events arrive too late for what you’re building.

The data block picks which parts of the game state CS2 sends:

ComponentWhat CS2 sends
providerThe SteamID of the client that sent the payload
player_idThe player’s name, SteamID, and team
player_stateHealth, armor, money, flashes, kills this round, and more
player_match_statsKills, assists, deaths, MVPs, and score for the match
mapThe map’s name, mode, and phase, and each team’s score
map_round_winsHow each round so far was won
roundThe round’s phase, the bomb’s status, and the winning team

pygsi can’t work without provider, because that’s how it knows whose game a payload came from (see Multiple Players).

CS2 only reads these files when it starts, so restart it after you add or change one.

Your SteamID64

pygsi tracks players by their SteamID64, the 17-digit number that starts with 7656. To find yours, type status in the CS2 console, or look yourself up on steamid.io.

Quick Start

In this chapter, we’ll write a script that prints a line when a round starts or ends, when we get a kill, and when we die. We assume you’ve installed pygsi and added the config file from Installation and CS2 Setup.

from pygsi import GSIServer, PlayerMatchStats, PlayerState, RoundState

gsi = GSIServer(player_ids="76561198000000000")  # your SteamID64


@gsi.on_round_start
async def round_start(player_id: str, old: RoundState | None, new: RoundState) -> None:
    state = gsi.state
    if state is not None and state.map is not None:
        print(f"Round {state.map.round} started on {state.map.name}")


@gsi.on_round_end
async def round_end(player_id: str, old: RoundState | None, new: RoundState) -> None:
    print(f"Round over, {new.winning_team} won")


@gsi.on_local_player_kill
async def kill(
    player_id: str, old: PlayerMatchStats | None, new: PlayerMatchStats
) -> None:
    print(f"Kill! That's {new.kills} this match")


@gsi.on_local_player_death
async def death(player_id: str, old: PlayerState | None, new: PlayerState) -> None:
    print("We died")


gsi.run()

The script starts by creating a GSIServer, which receives the payloads from CS2, and player_ids tells it whose game to follow. It listens on port 4213 unless we pass port=, and the port has to match the uri in the config file.

Each decorator registers an async handler for one event. Every handler gets the SteamID64 of the player the event is about, then old and new, one slice of the game state before and after the payload. Kill handlers get PlayerMatchStats, round handlers get RoundState, and so on. For a few events, like the round start, old is None when pygsi has nothing to compare with yet. Events has the full list.

In round_start, we read gsi.state, the latest full GameState for the player, which we can do anywhere, not only in a handler (see Game State). The last line, gsi.run(), starts the server and blocks until we stop it with Ctrl+C.

Let’s save it as main.py and run it:

python main.py

Now we start CS2 and join a match. Any mode works, including a practice match with bots. pygsi skips warmup, so nothing prints until the match goes live. If nothing shows up after that, check that CS2 was started after the config file was in place, and that the SteamID64 in the script is yours.

The repository’s example/ folder has a longer script that logs every event.

Events

CS2 doesn’t send events. Each payload is a snapshot of the game as it is right now, so pygsi works out the events itself by comparing each payload with the last one it stored for that player. When the round’s phase was freezetime before and is live now, a round has started.

Every event has a decorator on GSIServer, and every handler takes the same three arguments: the player_id the event is about, then old and new, the slice of state before and after the payload. This table lists each event, when it fires, and the type of that slice:

EventFires whenold and new
on_round_startThe round’s phase becomes liveRoundState
on_round_endThe round’s phase goes from live to overRoundState
on_bomb_plantedThe bomb becomes plantedRoundState
on_bomb_defusedThe bomb goes from planted to defusedRoundState
on_bomb_explodedThe bomb goes from planted to explodedRoundState
on_map_startThe first live payload of a new mapMapState
on_map_endThe map’s phase goes from live to gameoverMapState
on_local_player_killThe player’s match kills go upPlayerMatchStats
on_local_player_assistThe player’s match assists go upPlayerMatchStats
on_local_player_mvpThe player’s MVPs go upPlayerMatchStats
on_local_player_deathThe player’s health drops to 0PlayerState
on_state_updateEvery payload pygsi storesGameState

The type of old also allows None, but only four events ever pass it: on_round_start, on_bomb_planted, on_map_start, and on_state_update, when pygsi has no earlier state to compare with. The others only fire after a comparison, so their old is always set.

Handlers

A handler is an async def function, and we can register as many of them for one event as we like. Because each decorator hands back the function it was given, we can also stack decorators to have one function handle several events:

from pygsi import GSIServer, RoundState

gsi = GSIServer(player_ids="76561198000000000")


@gsi.on_bomb_defused
@gsi.on_bomb_exploded
async def bomb_done(player_id: str, old: RoundState | None, new: RoundState) -> None:
    print(f"The bomb is {new.bomb}")

Here, bomb_done runs when a planted bomb is either defused or explodes, and new.bomb tells us which.

Rounds

A round starts when its phase becomes live, and that’s when on_round_start fires. Usually it’s the end of freeze time, but if we start the script in the middle of a round, the first payload pygsi sees is already live, so the event fires then, with old set to None.

When the phase goes from live to over, on_round_end fires, and new.winning_team tells us who won.

The Bomb

The bomb events fire for every bomb in the player’s match, not only the ones the player plants or defuses. on_bomb_planted fires as soon as round.bomb becomes planted, even on the first payload pygsi sees. The other two are stricter, because they only fire when the payload before had a planted bomb. If pygsi starts after a plant, we won’t hear how that bomb ends.

Maps

pygsi ignores warmup, so on_map_start fires when warmup ends rather than when the map loads. More exactly, it fires on the first live payload pygsi sees for the player, with old set to None, and again on the first live payload of each new map after that, with old set to the map before. A new map is one that comes after a gameover payload, or has a different name, or has fewer rounds played than the last map pygsi stored. That last check catches a player who leaves a match early and joins another, since they never send a gameover payload. If the new match is on the same map and has played at least as many rounds as the old one, pygsi can’t tell them apart.

On a new map, pygsi compares nothing with the old one, so the round and bomb events treat its first payload like the first payload pygsi sees.

At the end of the map, the phase goes from live to gameover, which fires on_map_end with the final score in new. A gameover payload fires nothing else except on_state_update, which runs first, even when other things changed in it.

The Local Player

The kill, assist, and MVP events watch the player’s match totals in PlayerMatchStats, and they fire when one of those goes up. If two kills land in the same payload, we get one event, and new.kills is 2 higher than old.kills. These events compare with the last payload that had the player’s own data in the current map. They never fire on the first one pygsi sees, but they do catch what happened while the player was dead and spectating: an assist or MVP earned then fires as soon as the player’s data comes back, with old set to their stats from before they died.

A death is when health goes from above 0 to exactly 0. on_local_player_death fires once for it and stays quiet while the player is dead.

State Updates

When nothing else fits, we can use on_state_update, which fires for every payload pygsi stores and gets the whole GameState before and after. For example, here’s a handler that prints the player’s money:

from pygsi import GameState


@gsi.on_state_update
async def money(player_id: str, old: GameState | None, new: GameState) -> None:
    if new.player is not None:
        print(f"${new.player.state.money}")

Game State explains which payloads pygsi stores and which it skips.

Order

One payload can set off several events, like the last kill of a round that also ends the round. In that case, pygsi runs them in this order:

  1. on_state_update
  2. on_map_start
  3. on_round_start or on_round_end
  4. The bomb events
  5. The local player events

Each event finishes before the next one starts. If an event has more than one handler, though, pygsi runs those handlers at the same time with asyncio.gather and waits for all of them. By the time a handler runs, gsi.states already holds the new state.

Game State

A handler only gets one slice of the state, but it often needs more, like a kill handler that wants to know the map. For that, pygsi keeps the latest full state for each player it tracks, and we can read it whenever we like.

Reading State

With one tracked player, we read it from gsi.state, which is None until pygsi stores its first payload:

from pygsi import GSIServer, PlayerMatchStats

gsi = GSIServer(player_ids="76561198000000000")


@gsi.on_local_player_kill
async def kill(
    player_id: str, old: PlayerMatchStats | None, new: PlayerMatchStats
) -> None:
    state = gsi.state
    if state is not None and state.map is not None:
        print(f"Kill on {state.map.name}, round {state.map.round}")

A GameState has a map, a round, and a player, and any of them can be None, which is why the handler checks state.map before using it. Types lists every field. When we track more than one player, we use gsi.states instead, which Multiple Players covers.

Which Payloads Count

CS2 sends payloads all the time, including in menus and during warmup. pygsi stores a payload, and runs handlers for it, only when all of these hold:

  • It has a map block, so the player is on a map.
  • Its provider is one of the players we track.
  • The map’s phase is live or gameover.

Everything else is dropped, and the stored state stays as it was. That includes warmup, the menus, and intermission, the break at halftime. During halftime, gsi.state still shows the last payload from before it.

Note

CS2 counts the rounds already finished in map.round, and pygsi adds one, so during a round it’s that round’s number, starting at 1. CS2 updates its count as soon as a round is over, though, so once the round’s phase is over, and after the map ends, map.round is already the number of the round after it.

Spectating After Death

When the tracked player dies, CS2 moves their camera to a teammate, and its payloads start carrying that teammate’s data in the player block. pygsi catches this by comparing the player block’s SteamID with the provider’s, and when they differ, it sets player to None. While the player is dead and spectating, then, state.player is None and the local player events don’t fire, but the map and round keep updating. The same check applies to the gameover payload.

Multiple Players

One server can follow several players at once, with each player running CS2 on their own machine and the same config file pointing them all at that server.

Tracking Several Players

To track more than one player, we pass a list of SteamID64s:

from pygsi import GSIServer, RoundState

gsi = GSIServer(player_ids=["76561198000000001", "76561198000000002"])


@gsi.on_round_end
async def round_end(player_id: str, old: RoundState | None, new: RoundState) -> None:
    print(f"{player_id}: round over, {new.winning_team} won")

Warning

Each player’s uri has to reach the server from their machine. 127.0.0.1 only works for the player on the machine running the server. Everyone else needs that machine’s address, and the server has to listen on it, which it does by default (see GSIServer).

Per-Player State

pygsi keeps each player’s state apart from everyone else’s. We get at it through gsi.states, a dictionary from each SteamID64 to that player’s GameState, or to None before their first payload:

for steamid, state in gsi.states.items():
    if state is not None and state.player is not None:
        print(steamid, state.player.match_stats.kills)

The shortcut gsi.state raises RuntimeError when there’s more than one player, since it can’t know whose state we want.

Routing

To decide whose payload it got, pygsi reads the provider block, which always names the CS2 client that sent it. It doesn’t use the player block, because that switches to someone else when the player dies and spectates (see Spectating After Death). Two tracked players in the same match never mix up their states, then, even when one is watching the other.

Logging and Errors

CS2 stops sending updates to a server that answers with an error, so pygsi always answers with 200 OK, whatever goes wrong. It logs the problem instead, which means the log is where to look when something doesn’t work.

Logs

pygsi logs through Python’s logging module, under the logger name pygsi.server. At the DEBUG level, it also logs every raw payload as indented JSON, which helps when you want to see exactly what CS2 sent:

import logging

logging.basicConfig(level=logging.INFO)
logging.getLogger("pygsi.server").setLevel(logging.DEBUG)

The payloads are long and arrive often, so the example sends them to their own file.

Errors in Handlers

When a handler raises an exception, pygsi logs it with its traceback and carries on, so the other handlers and events for that payload still run. A payload that isn’t valid JSON, or doesn’t match the models, gets logged and dropped, and the stored state stays as it was.

Slow Handlers

pygsi runs the handlers for a payload before it answers CS2, and CS2 doesn’t send its next payload until it has that answer, which means no new updates arrive while a handler is busy. If the handlers take longer than the timeout in the config file (5 seconds in ours), CS2 counts the request as failed and sends the full state again next time.

Handlers should finish quickly for that reason. When one has slow work to do, like a request to a web API, it can start a task and return right away:

import asyncio

from pygsi import GSIServer, PlayerMatchStats

gsi = GSIServer(player_ids="76561198000000000")
background: set[asyncio.Task[None]] = set()


async def post_kill(kills: int) -> None:
    await asyncio.sleep(3)  # stands in for a slow request
    print(f"Posted {kills} kills")


@gsi.on_local_player_kill
async def kill(
    player_id: str, old: PlayerMatchStats | None, new: PlayerMatchStats
) -> None:
    task = asyncio.create_task(post_kill(new.kills))
    background.add(task)
    task.add_done_callback(background.discard)

The background set keeps a reference to each task until it’s done, because asyncio only keeps a weak one, and a task with no other reference can disappear before it finishes.

GSIServer

GSIServer receives payloads from CS2, keeps the state of each tracked player, and runs event handlers. It’s a small FastAPI app with one route, POST /, run by uvicorn.

class GSIServer:
    def __init__(
        self,
        player_ids: str | Sequence[str],
        port: int = 4213,
        host: str = "0.0.0.0",
    ) -> None: ...
ParameterDefaultMeaning
player_idsThe SteamID64 of each player to track, as one string or a sequence of strings. Payloads from other players are dropped.
port4213The port to listen on. It has to match the uri in the CS2 config file.
host"0.0.0.0"The address to listen on. The default listens on every network interface.

Warning

With the default host, other machines on your network can send the server payloads too. If CS2 and pygsi run on the same machine, pass host="127.0.0.1".

Properties

player_ids is the frozenset[str] of tracked SteamID64s.

states is a dict[str, GameState | None] from each tracked SteamID64 to that player’s latest state. A player’s value is None until their first stored payload.

state is the latest GameState | None of the only tracked player. It raises RuntimeError when more than one player is tracked.

Methods

run() starts the server with uvicorn.run and blocks until the process is interrupted. uvicorn creates and runs its own event loop, so run() can’t be called from code that’s already inside one.

Event Decorators

Each event has a decorator, such as on_round_start, which registers an async handler and returns it unchanged. A handler takes (player_id: str, old: T | None, new: T) and returns None, where T depends on the event. Events lists every event with its T.

Types

Every type here can be imported from pygsi. The models are Pydantic models, and the enums are StrEnums, so each member equals its string value: RoundPhase.LIVE == "live".

GameState

The full state of one player’s game.

FieldTypeMeaning
mapMapState | NoneThe map and the score
roundRoundState | NoneThe current round
playerPlayer | NoneThe tracked player, or None when the payload has no data for them, such as while they’re dead and spectating

MapState

FieldTypeMeaning
namestrThe map’s name, such as "de_dust2"
modestrThe game mode, such as "competitive"
phaseMapPhaseThe map’s phase
roundintThe number of rounds finished, plus one. During a round, that’s the round’s number.
team_ct_scoreintRounds won by CT
team_t_scoreintRounds won by T
round_winsdict[str, str]How each round was won, by round number, such as {"1": "ct_win_elimination"}. Empty unless the config has map_round_wins.

RoundState

FieldTypeMeaning
phaseRoundPhaseThe round’s phase
bombBombStatus | NoneThe bomb’s status, or None if it isn’t planted
winning_teamTeam | NoneThe team that won the round, set once the phase is over

Player

FieldTypeMeaning
steamidstrThe player’s SteamID64
namestrThe player’s name
teamTeamThe player’s team
activityActivity | NoneWhat the player is doing in the game client
statePlayerStateHealth, money, and so on
match_statsPlayerMatchStatsTotals for the match

PlayerState

FieldTypeMeaning
healthintHealth, from 0 to 100
armorintArmor, from 0 to 100
helmetboolWhether the player has a helmet
flashedintHow flashed the player is, from 0 to 255
smokedintHow far inside a smoke the player is, from 0 to 255
burningintHow much the player is burning, from 0 to 255
moneyintMoney
round_killsintKills this round
round_killhsintHeadshot kills this round
equip_valueintThe total value of the player’s equipment

PlayerMatchStats

FieldTypeMeaning
killsintKills this match
assistsintAssists this match
deathsintDeaths this match
mvpsintMVPs this match
scoreintScore this match

Enums

EnumMembers
MapPhaseWARMUP ("warmup"), LIVE ("live"), INTERMISSION ("intermission"), GAMEOVER ("gameover")
RoundPhaseFREEZETIME ("freezetime"), LIVE ("live"), OVER ("over")
BombStatusPLANTED ("planted"), DEFUSED ("defused"), EXPLODED ("exploded")
TeamT ("T"), CT ("CT")
ActivityPLAYING ("playing"), MENU ("menu"), TEXT_INPUT ("textinput")

pygsi only stores payloads from live and finished maps (see Game State), so a stored MapState has the phase LIVE or GAMEOVER.

Limitations

This page lists what pygsi doesn’t do. Some of it is CS2’s limit, because the game sends a player less than it sends an observer, and some is pygsi’s own.

What CS2 Doesn’t Send Players

Some GSI components only carry data for spectators and observers, such as casters and tournament tools:

  • allplayers, allplayers_state, allplayers_match_stats, allplayers_weapons, and allplayers_position, with data on every player in the match
  • bomb, with the bomb’s position and carrier
  • allgrenades, with every grenade in the air
  • phase_countdowns, with the timers for each phase
  • player_position, with the player’s position

During a match, a player’s own client sends nothing for these, so pygsi doesn’t model them. That also means pygsi can’t say who the player killed, who killed them, or who planted the bomb. The draft CS2 GSI spec lists every component and what CS2 sends for each.

What pygsi Doesn’t Do

  • Handlers must be async. There’s no support for plain def handlers.
  • run() owns the event loop. It calls uvicorn.run, which creates its own loop and blocks. To share a process with other async code, such as a Discord bot, you have to run pygsi in its own thread.
  • The config file’s auth block is ignored. CS2 can send a token with each payload, but pygsi doesn’t check it. Anyone who can reach the server can send it payloads, which is one more reason to bind to 127.0.0.1 when you can.
  • Handler signatures aren’t type-checked. The decorators accept any async function, so a handler with the wrong signature only shows up at runtime, as an error in the log.
  • Weapons aren’t modeled. CS2 sends a player’s weapons in the player_weapons component, but pygsi doesn’t read it.
  • Nothing is saved. State lives in memory and is gone when the process stops.

CS2 Game State Integration Spec

Note

This spec is a draft. It will change as more CS2 payloads are captured and the open items get settled.

Valve has never published a spec for CS2. The only official document is Valve’s CS:GO page, and CS2 kept the same mechanism and config format. This spec takes that page and checks it against payloads CS2 actually sent.

Each fact is tagged with its evidence:

  • [V] Valve’s page. It’s written for CS:GO, and the live page blocks automated clients, so it was read through the Internet Archive.
  • [C] Payloads captured from CS2, in pygsi’s tests/fixtures.json. They come from a practice match against bots on de_dust2 (provider.version 14141), plus one payload from a community server. The previously and added blocks were stripped before they were saved. [C] also covers what pygsi’s git history records about earlier runs against CS2, cited by commit.
  • [B] u/Bkid’s Game State Integration: A Very Large and In-Depth Explanation (2019), a detailed write-up built from payloads captured in CS:GO. Much of CS:GO’s GSI carried over unchanged, so it’s the guide where CS2 data is missing, but each [B] fact still needs a CS2 payload to confirm it.

When sources disagree, the captured payloads and pygsi’s tested behavior win, then Valve, then [B]. Anything not confirmed in CS2 is marked open and listed under Open Items. Where [B] covers an open item, it’s the expected answer. Anything that only other GSI implementations suggest is listed as a lead to check, not as a fact.

Structure

These are the keys a payload can have. Fields marked [C] have been seen in a CS2 payload. The others come from Valve’s descriptions of the components.

payload
+-- auth                           [V] only with an "auth" block in the config
+-- provider                       [C]
|   +-- name, appid, version, steamid, timestamp
+-- map                            [C]
|   +-- mode, name, phase, round, num_matches_to_win_series
|   +-- team_ct, team_t
|   |   +-- score, name, flag, consecutive_round_losses,
|   |       timeouts_remaining, matches_won_this_series
|   +-- round_wins                 [C] with map_round_wins
|       +-- "1", "2", ...
+-- round                          [C]
|   +-- phase, bomb, win_team
+-- player                         [C]
|   +-- steamid, name, observer_slot, team, activity
|   +-- clan                       [V] open
|   +-- state                      [C] with player_state
|   |   +-- health, armor, helmet, flashed, smoked, burning, money,
|   |       round_kills, round_killhs, equip_value
|   +-- weapons                    [C] with player_weapons
|   |   +-- weapon_0, weapon_1, ...
|   |       +-- name, paintkit, type, state,
|   |           ammo_clip, ammo_clip_max, ammo_reserve
|   +-- match_stats                [C] with player_match_stats
|       +-- kills, assists, deaths, mvps, score
+-- allplayers, bomb, phase_countdowns, grenades
|                                  [V] observer-only, open
+-- previously                     [V] old values of what changed
+-- added                          [V] keys that weren't there before

1. The Config File

CS2 reads every file named gamestate_integration_<name>.cfg in game/csgo/cfg/ when it starts, and sends updates to each one [V][C]. A file saved with a UTF-8 BOM doesn’t load, and the console lists the files that did [V].

Valve’s sample for a player’s own client [V]:

"Console Sample v.1"
{
 "uri" "http://127.0.0.1:3000"
 "timeout" "5.0"
 "buffer"  "0.1"
 "throttle" "0.5"
 "heartbeat" "60.0"
 "auth"
 {
   "token" "CCWJu64ZV3JHDT8hZc"
 }
 "output"
 {
   "precision_time" "3"
   "precision_position" "1"
   "precision_vector" "3"
 }
 "data"
 {
   "provider"            "1"
   "map"                 "1"
   "round"               "1"
   "player_id"           "1"
   "player_state"        "1"
   "player_weapons"      "1"
   "player_match_stats"  "1"
 }
}

Endpoint Settings [V]

KeyDefaultMeaning
urinoneWhere the game sends its POST requests. For an https URI, the Steam client uses TLS and validates the server’s certificate.
timeout1.1 sHow long the game waits for a response. After a timeout, the request counts as failed, and the next one sends the full state with no deltas.
buffer0.1 sAfter a change, the game collects more changes for this long and reports them together. 0.0 turns buffering off.
throttle1.0 sThe game sends nothing for at least this long after a 2xx response.
heartbeatnot givenThe game sends a request this long after the last 2xx response, even if nothing changed.

The game expects a 2xx response, and it doesn’t send a new request while one is still in flight [V]. Valve doesn’t say what a non-2xx response does, beyond counting the request as failed. If an endpoint never sees a previously or added block, the game is probably treating every request as failed [V].

auth [V]

Optional. Each field in the config’s auth block is sent to the endpoint as a JSON string field, so the endpoint can check where the payload came from. Valve recommends https when you use it. Open.

output [V]

Optional. Sets how many digits after the decimal point the game sends: precision_time for durations such as countdowns and lifetimes, precision_position for positions, and precision_vector for vectors such as velocity and forward direction.

data Components

Each component turns on one part of the payload. Valve’s list [V]:

ComponentWhat it addsWho gets it
providerThe client sending the payloadEveryone
mapMode, map, phase, and scoreEveryone
map_round_winsHow each round so far was wonEveryone
roundRound phase, bomb state, round winnerEveryone
player_idName, SteamID, clan tag, observer slot, teamEveryone
player_stateHealth, armor, flashes, kills this round, and so onEveryone
player_weaponsEquipped weapons, ammo, and weapon stateEveryone
player_match_statsKills, assists, deaths, MVPs, scoreEveryone
player_positionPosition and forward direction of the spectated playerObservers only
allplayers_id, allplayers_state, allplayers_match_stats, allplayers_weapons, allplayers_positionThe player_* data for every playerObservers only
bombWhere the bomb is, who’s carrying it, whether it’s droppedObservers only
phase_countdownsTime left in the current phase, and which phaseObservers only
allgrenadesEvery grenade’s owner, position, velocity, type, lifetime, and effect timeObservers only

An observer is a client that’s spectating a match, watching GOTV, or watching a demo. A player in a match gets nothing from the observer-only components, which means no bomb timer and no data on other players [V].

2. The Payload

Each request is an HTTP POST with a JSON body. It holds the full current state of every component in the config, plus two blocks computed against the last payload that got a 2xx response [V]:

  • previously holds the old values of the data that changed.
  • added holds the root fields that are in the new state but weren’t in the old one.

A component with no data at the moment is left out [C]. In the main menu, for example, a payload has provider and a player with only steamid, name, and activity. During warmup, there’s a map but no round [C].

provider [C]

FieldTypeSeen in CS2
namestring"Counter-Strike: Global Offensive", unchanged in CS2
appidint730
versionint14141
steamidstringThe SteamID64 of the client that sent the payload. It stays the same while the player spectates someone else.
timestampintUnix time in seconds

map [C]

FieldTypeSeen in CS2
modestringcompetitive. Other modes are open.
namestringde_dust2
phasestringwarmup, live, gameover. Valve also lists intermission, for halftime [V], which is open.
roundintThe number of rounds already finished. It’s 0 in the first round and goes up as soon as a round’s phase becomes over. At gameover it equals the total rounds played.
num_matches_to_win_seriesint0
team_ct, team_tobjectSee below
round_winsobjectOnly with map_round_wins. The keys are round numbers starting at "1".

Each team object has these fields:

FieldTypeSeen in CS2
scoreintRounds won
namestring"CounterTerrorists", "Terrorists"
flagstringA country code, such as "us" or "de"
consecutive_round_lossesint
timeouts_remainingint1
matches_won_this_seriesint0

name and flag are strings, and the other team fields are ints. The community-server payload has the same shape and types as the practice-match ones [C].

The round_wins values seen so far are ct_win_elimination, t_win_elimination, and t_win_bomb. Other win conditions, such as a defuse or the timer running out, are open.

round [C]

FieldTypeSeen in CS2
phasestringfreezetime, live, over
bombstringplanted, exploded. Left out until the bomb is planted. Valve also lists defused [V], which is open.
win_teamstringCT or T. Present once the phase is over.

player [C]

After the player dies, CS2 fills player with the data of the teammate they’re spectating, while provider.steamid stays theirs. The only way to tell is to compare player.steamid with provider.steamid [C]. Bots have short IDs such as "503", not SteamID64s [C].

FieldTypeSeen in CS2
steamidstring
namestring
observer_slotintPresent for the local player as well as a spectated teammate, such as 5 and 9.
teamstringT. CT hasn’t been captured in this field yet, though it appears in round.win_team.
activitystringplaying, menu. [B] adds textinput, for the console, which is open.
clanstringThe clan tag [V]. Open.

player.state, with player_state:

FieldTypeSeen in CS2
healthint0 to 100
armorint0 seen
helmetboolfalse seen
flashedint0 seen. How flashed the player is.
smokedint0 seen. How far inside a smoke the player is.
burningint0 seen. How much the player is burning.
moneyint
round_killsintKills this round
round_killhsintHeadshot kills this round
equip_valueintThe value of everything the player has

Ranges for flashed, smoked, and burning aren’t in Valve’s page and haven’t been measured yet.

player.weapons, with player_weapons, is an object with the keys weapon_0, weapon_1, and so on. Each weapon has:

FieldTypeSeen in CS2
namestringweapon_ak47, weapon_deagle, weapon_glock, weapon_knife_t, weapon_c4, weapon_smokegrenade
paintkitstringThe skin’s internal name, such as cu_desert_eagle_corroden, or default
typestringRifle, Pistol, Knife, Grenade, C4
statestringactive, holstered, reloading
ammo_clipintRounds in the magazine. Left out for knives, grenades, and the C4.
ammo_clip_maxintMagazine size, left out in the same cases.
ammo_reserveintReserve ammo. A grenade has this field and nothing else about ammo.

player.match_stats, with player_match_stats: kills, assists, deaths, mvps, score, all ints.

Observer-Only Blocks

Valve names these blocks and what they contain, but none of them has been captured from CS2, so their exact fields aren’t known yet [V]:

  • allplayers: the player_* data for every player.
  • bomb: the bomb’s position, its carrier, and whether it’s dropped.
  • phase_countdowns: the time left in the current phase and which phase it is.
  • grenades, from allgrenades: each grenade’s owner, position, velocity, type, lifetime, and effect time.

3. Behavior

  • Snapshots, not events. Every payload is the full state, so events have to be worked out by comparing payloads, or from previously and added [V].
  • One request at a time. The game waits for each response before it sends the next request, so a slow endpoint delays every update after it [V].
  • Spectating after death. Once the player dies, player switches to the teammate they’re watching, and provider doesn’t change [C].
  • Round counter. map.round goes up as soon as a round is over, not when the next round starts [C].
  • No kill feed. No component says who killed whom, or with what [V].

4. Open Items

These need a captured payload, or a test against a real client, before the spec can state them. Where other GSI implementations expect something, it’s listed as a lead.

Protocol

  1. Non-2xx responses. Valve says a failed request makes the next one send the full state, but not whether the game slows down or stops after repeated failures. pygsi always answers 200 to be safe.
  2. heartbeat default. Valve gives none. [B]: 30 s.
  3. The shape of previously and added. Valve describes them in words only, and the captured payloads had them stripped. [B]: previously mirrors the payload’s nesting with only the changed fields, such as {"player": {"state": {"flashed": 24}}}, and added marks each new key with true, such as {"player": {"clan": true}}.
  4. auth in the payload. [B]: the config’s auth fields arrive as strings, and the key doesn’t have to be token.
  5. A provider-only config. [B]: a change to provider.timestamp alone doesn’t trigger a request, so such a config only gets heartbeats.

Values Not Yet Seen

  1. map.mode. Only competitive is captured. [B]: casual, deathmatch, gungameprogressive, scrimcomp2v2. Leads for CS2: wingman in place of scrimcomp2v2, custom, workshop, new_user_training, retakes, survival.
  2. map.phase. [V][B]: intermission during halftime.
  3. round.bomb. [V][B]: defused.
  4. round.phase. Only freezetime, live, and over are captured. [B]: freezetime also covers team timeouts.
  5. round_wins. Only ct_win_elimination, t_win_elimination, and t_win_bomb are captured. [B]: ct_win_defuse, ct_win_time. Leads: ct_win_rescue, t_win_time.
  6. player.team. Only T is captured in this field. [B]: T or CT.
  7. player.activity. [B]: textinput while the console is open. It describes the client itself, even while spectating.
  8. Weapon type. [B]: SniperRifle, Submachine Gun. Leads: Shotgun, a machine gun type, and types for the Zeus, fists, melee weapons, and tablets.
  9. Ranges. [B]: flashed, smoked, and burning run from 0 to 255, and burning is 255 while on fire and then counts down after leaving it. money runs up to 16000 in competitive.
  10. player.observer_slot. [B] numbers the slots 1 to 9, then 0, and says the field only appears while spectating. The captured payloads have it for the local player too, so the second part doesn’t hold for CS2.

Fields Not Yet Seen

  1. player.clan [V]. [B]: left out when the player has no clan tag.
  2. player.state. pygsi’s first version modeled round_totaldmg and defusekit, and removed both because CS2 never sent them in real runs (commit d72d174) [C]. Those runs may not have included a CT with a kit, so defusekit could still appear then. Lead: health_c4_preview.
  3. player.xpoverload. A lead only.
  4. map. [B]: current_spectators and souvenirs_total.
  5. tournamentdraft. A lead only: a block with pick and ban details for tournaments.
  6. Observer-only blocks. [B] has examples of these:
    • bomb has state (carried, dropped, planting, planted, defusing, defused, and, per Valve’s round values, exploded), position, player (the SteamID64 of whoever carries, plants, or defuses it), and countdown. countdown is the time to finish planting while planting, the time to explode while planted, and the time to finish defusing while defusing.
    • phase_countdowns has phase (the round phases plus bomb, defuse, and warmup) and phase_ends_in.
    • player.spectarget, player.position, and player.forward come with player_position.
    • Positions and vectors are "x, y, z" strings, and countdowns are strings such as "39.8".
    • Leads: allplayers keyed by SteamID64, each value shaped like player, and grenades keyed by ID, with owner, position, velocity, lifetime, type, effecttime, and flames.

Behavior

  1. Death and spectating. Is the first payload after a death always the player’s own data with health 0, or can it already show the teammate? pygsi’s death event depends on the first case.
  2. The gameover payload while spectating. The captured gameover payload has no player block, so it’s unclear whether one can show a teammate.

To close most of these, run a capture session with every component on and save each raw payload, previously and added included. It should cover a competitive match through halftime, a defuse, and a round lost on time. It should include a round as CT with a kit, armor, and a helmet, and a game in casual, deathmatch, and wingman. Finally, it should include spectating a demo, for the observer-only blocks.