Skip to main content

gem: a Dota 2 replay parser for Python

Turn Dota 2 replays into analysis-ready Python data.
Parse Source 2 .dem files offline into typed models, pandas DataFrames, JSON and Parquet.

PyPI version Python versions CI status Coverage License

Documentation · Quickstart · Recipes · API reference · Changelog


gem reads a replay the way the game recorded it: every entity update, combat-log entry and chat event, rebuilt into one ParsedMatch. It runs offline, needs no API keys, and handles both the old and new combat-log formats.

Facts, not verdicts. gem reports what happened: who was where, what they did, what it cost and what followed. It doesn't score plays or decide whether a Roshan "converted"; the recipes show how to answer questions like that from the facts, in code you can change.

Patch 7.42: gem has caught up with Dota 2 patch 7.42 (constants, camps, fountain anchors, Tormentor drops, and gold ledger fields) and has been checked against tournament and ranked replays across all 127 heroes. Because 7.42 is still new, do expect the occasional edge case here and there — if you hit one, please open an issue with the match ID.

Install

gem needs Python 3.10 or newer.

# pip
pip install gem-dota

# uv (in a project)
uv add gem-dota

# uv (pip interface)
uv pip install gem-dota

# Poetry
poetry add gem-dota

Parquet export also needs pyarrow or fastparquet (engine notes).

Quickstart

import gem

match = gem.parse("match.dem")

print(f"Score: {match.radiant_score}–{match.dire_score}")
for player in match.players:
    hero = gem.constants.hero_display(player.hero_name)
    print(f"{hero:20} {player.kills}/{player.deaths}/{player.assists}  {player.net_worth:,} NW")

No replay yet? gem.fetch_replay(match_id, "replays/") downloads and decompresses one through OpenDota (Valve keeps replays for a limited time).

Prefer tables?

frames = gem.parse_to_dataframe("match.dem")
frames["player_summary"]      # one row per player
frames["player_timeseries"]   # sampled gold, XP and net worth
frames["positions"]           # hero positions over time
frames["combat_log"]          # every normalized combat-log entry

Or the command line:

python -m gem match.dem
python -m gem match.dem --format json --output match.json
python -m gem batch replays/ --format parquet --output out/ --workers 4

What you get

Domain Examples
Match and players Score, winner, duration, teams, K/D/A, level, GPM/XPM, final net worth
Draft and objectives Picks and bans, towers, barracks, Roshan and the Aegis, Tormentors, building status
Combat The normalized combat log, damage and healing, kills, ability and item use, fights
Economy Gold, XP and net-worth curves, minute-aligned advantages, purchases, a per-player gold ledger, exact buyback costs
Map Hero positions, map regions, neutral camps, lane heatmaps, wards, smoke groups, couriers, runes
Items Final inventories, neutral-item finds, consumed upgrades, Roshan drops, banner plants
Lookups Position, net worth or ability level at a tick, nearby heroes, the fight at a tick, hero visibility
Exports Dataclasses, DataFrames, JSON, Parquet, parallel multi-replay batches

gem's map regions and the 28 neutral camps on the 7.41 map
gem's map model: the river, both halves, the lotus pools and all 28 neutral camps, checked against the replays. gem.region_of(x, y) labels any position.

Good entry points:

  • gem.parse() → ParsedMatch; gem.parse_many() for parallel batches
  • gem.parse_to_dataframe(), gem.to_json() / gem.load_json(), gem.to_parquet()
  • gem.find_player(), gem.position_at_tick(), gem.fight_at_tick(), gem.region_of()
  • gem.fetch_replay() to download and decompress a replay by match ID

Recipes

The recipes answer one question each from gem's facts and pandas. Every page has a figure for one match, the answer across the test replays, and the code to run on yours:

The code lives in examples/cookbook/:

python examples/cookbook/fights.py replays/*.dem

Accuracy

gem is an independent Python implementation, checked against the Manta, Clarity and OpenDota parsers at pinned revisions. On the test replays and a 57-match patch 7.42 tournament + ranked corpus (November 2026), its per-player totals (K/D/A, last hits, net worth, GPM/XPM, hero and tower damage, healing, wards, stacks, runes, buybacks) and per-minute gold, XP, last-hit and deny curves match OpenDota exactly. Replays with an embedded postgame summary give exact final gold, net worth and spending; older or incomplete replays fall back to replay-derived values, and fields whose absence means something stay None.

Some outputs are reconstructed rather than recorded:

  • Farming routes, smoke analysis, fight positioning and Roshan records are experimental: they join replay facts with documented, inspectable rules.
  • A truncated or corrupt replay returns what was read, with parse_error and truncated_at_tick set.
  • Healing Lotus pickups aren't in the replay's event stream.

See Replay Edge Cases for the details.

Performance

gem is pure Python, built for research and batch analysis. A 40-minute professional match parses in about a minute and a half on an Apple M2; gem.parse_many() spreads replays across processes, and bounded Parquet export doesn't keep every finished match in memory. The performance study has the method and numbers.

Documentation

Development

git clone https://github.com/whanyu1212/gem-dota.git
cd gem-dota
uv sync --group dev

uv run pytest                                   # fast suite
uv run pytest -m "integration and not network"  # full replays (sync them first)
uv run ruff check . && uv run mypy src/gem/

Contributions are welcome: CONTRIBUTING.md has the workflow and PR checklist. Parser changes are checked against the upstream revisions pinned in upstream-refs.lock.json (see CLAUDE.md) and come with focused regression tests.

Acknowledgements

gem builds on years of open work by the Dota replay community: Manta, Clarity, the OpenDota parser, dotaconstants and SteamTracking/Protobufs. No source code was copied from these projects: they are the references used to understand the protocol and to validate gem's own implementation. See THIRD_PARTY_LICENSES for license texts.

gem is named after the Gem of True Sight: it reveals the match hidden in the replay's bytes.

Sponsor gem

Metadata

Release files for gem-dota 0.15.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 gem-dota 0.15.0
File Size Uploaded Provenance Actions
gem_dota-0.15.0.tar.gz 1.2 MB Without provenance Details for gem_dota-0.15.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gem-dota 0.15.0
File Interpreter ABI Platform Actions
gem_dota-0.15.0-py3-none-any.whl Python 3 none any Details for gem_dota-0.15.0-py3-none-any.whl

Total release size: 2.5 MB

Release files / gem_dota-0.15.0.tar.gz

Download URL gem_dota-0.15.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0062765325c9b772f58b81f63b9123b0bfbae9eda38d281f375198bb6fdb2bd4
BLAKE2b-256 checksum
How to use checksums
249e38b83eb21eaefd59c3a6e2061743dbeb38cae8374b7a834fb4d9698fa88e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / gem_dota-0.15.0-py3-none-any.whl

Download URL gem_dota-0.15.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7d89e16c7e5cc8f4e0d97f6fd0c757e64f058ada3481976ea4ba570bca91af63
BLAKE2b-256 checksum
How to use checksums
a2bd84a417d01938f7257c811a5897cfc1c51e35ddd2a5818599b820947e4047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for gem-dota 0.15.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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