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.

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.

The book's CS2 GSI spec describes the GSI protocol itself: the config file, every payload field, and what CS2 actually sends. It's a draft, checked against captured payloads, and it will change as the open items it lists get settled.

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.2

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.2
File Size Uploaded Provenance Actions
pygsi_cs2-0.1.2.tar.gz 8.7 kB With provenance Details for pygsi_cs2-0.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 18.4 kB

Release files / pygsi_cs2-0.1.2.tar.gz

Download URL pygsi_cs2-0.1.2.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7d36ef432d82d578b5f482ef9ceac148ed777765783f8385cdaeb97ab905d7a
BLAKE2b-256 checksum
How to use checksums
780a43e3304b4a27aa71bcb8d3152ce7dbaedb8660abf2b532be22026126b08d
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.2-py3-none-any.whl

Download URL pygsi_cs2-0.1.2-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0976ddabbba89c0091ff05cac3109d4ac73d8a0243d786f7a3130d7e77ac33ef
BLAKE2b-256 checksum
How to use checksums
713a40a5f0798b090089cdd0480b104385eec3f1f854ac818e0811cae8b4258d
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.2

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.2.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