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.