Skip to main content

pygsi

PyPI CI License: MIT

A Python library to interface with CS2's Game State Integration (GSI).

pygsi runs the server that CS2 sends its game state to while you play. It parses each payload into typed Pydantic models, keeps the latest state for each player it tracks, and calls your async handlers when something happens, like a round starting, the bomb being planted, or a kill. It's built for players in a match, one or several at once, not for spectators or observers.

Status

pygsi is in active development, so expect breaking changes between minor versions before 1.0.

Getting Started

pygsi needs Python 3.11 or newer. It's called pygsi-cs2 on PyPI, and you import it as pygsi:

pip install pygsi-cs2

CS2 also needs a config file that tells it where to send updates. Installation and CS2 Setup has the file and where to put it. Then a script like this prints a line for every kill:

from pygsi import GSIServer, PlayerMatchStats

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


@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.run()

The Quick Start walks through a longer version, and example/ has a script that logs every event.

Documentation

The book covers the events, the game state, tracking several players, and every type. To build it locally, install mdBook and run mdbook serve docs --open.

Development

You'll need uv. CI runs these checks:

uv sync --group dev --group test
uv run ruff format --check src tests example
uv run ruff check src tests example
uv run mypy src
uv run pytest tests

The tests replay real CS2 payloads from a practice match, stored in tests/fixtures.json, so they don't need the game.

License

MIT

Metadata

Release files for pygsi-cs2 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygsi-cs2 0.1.0
File Size Uploaded Provenance Actions
pygsi_cs2-0.1.0.tar.gz 8.3 kB With provenance Details for pygsi_cs2-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygsi-cs2 0.1.0
File Interpreter ABI Platform Actions
pygsi_cs2-0.1.0-py3-none-any.whl Python 3 none any Details for pygsi_cs2-0.1.0-py3-none-any.whl

Total release size: 17.6 kB

Release files / pygsi_cs2-0.1.0.tar.gz

Download URL pygsi_cs2-0.1.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
38252761a9d52684da519e9bc36c7c6b124fded2a937a0edd5ec1d2683466aa1
BLAKE2b-256 checksum
How to use checksums
940dde7114fc2cc7416f32a409507d2919693c5c03989f335dba47908ef20be1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / pygsi_cs2-0.1.0-py3-none-any.whl

Download URL pygsi_cs2-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d289cb0fa73f698d837616eec7b64236c885fdc89130c86690f23dfbdacce59
BLAKE2b-256 checksum
How to use checksums
fee49b1f245b3e262789382d06fbf1b2bf2839883b907fd986401429467f94fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for pygsi-cs2 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pygsi_cs2-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page