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.

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

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.1
File Size Uploaded Provenance Actions
pygsi_cs2-0.1.1.tar.gz 8.3 kB With provenance Details for pygsi_cs2-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 17.5 kB

Release files / pygsi_cs2-0.1.1.tar.gz

Download URL pygsi_cs2-0.1.1.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7716fabc11f7116fe7957f294384c455b2229833ad311f76f1d39713c8e747ad
BLAKE2b-256 checksum
How to use checksums
ec6062edb91f9da3ea409567d814bc2b00cb249260c6598169c3146fbcfb2496
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.1-py3-none-any.whl

Download URL pygsi_cs2-0.1.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c22a77ba7bb438605aece4dbca91779737d301731fc897a18ea72294cd5b4ee2
BLAKE2b-256 checksum
How to use checksums
55b426b15dcc2f433931c90183cbe2ff8edc6e5f96551b7f0fbb38f9dd196028
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.1

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