Rocket League Stats API client
Project description
Rocket League Stats API
rlstatsapi is a simple and fast Python client for reading live Rocket League Stats API events over a local TCP socket.
Click here for full documentation
Install
From PyPI:
pip install rlstatsapi
From GitHub (latest main):
pip install git+https://github.com/manucabral/RocketLeagueStatsAPI.git
Rocket League setup
Before launching Rocket League, edit:
<Install Dir>\TAGame\Config\DefaultStatsAPI.ini
Use at least:
PacketSendRate=30(any value> 0enables the exporter)Port=49123
Restart the game after changing the file.
Quick start
import asyncio
from rlstatsapi import StatsClient
async def main() -> None:
async with StatsClient() as client:
client.on_any(lambda msg: print(msg.event, msg.data))
await asyncio.Event().wait()
asyncio.run(main())
Demos
Typed event handlers
Every known event has a typed convenience method. No manual casting needed.
import asyncio
from rlstatsapi import StatsClient, TypedEventMessage, GoalScoredPayload
async def on_goal(msg: TypedEventMessage[GoalScoredPayload]) -> None:
scorer = msg.data.get("Scorer", {})
speed = msg.data.get("GoalSpeed", 0.0)
print(f"Goal by {scorer.get('Name')} at {speed:.0f} km/h")
async def main() -> None:
async with StatsClient() as client:
client.on_goal_scored(on_goal)
await asyncio.Event().wait()
asyncio.run(main())
The decorator form of on() is also supported:
@client.on("GoalScored")
async def on_goal(msg: TypedEventMessage[GoalScoredPayload]) -> None:
...
Connection events
client.on_connect(lambda: print("Connected"))
client.on_disconnect(lambda: print("Disconnected"))
Error handling
def on_error(event_name: str, exc: Exception) -> None:
print(f"Handler error for {event_name}: {exc}")
client.on_handler_error(on_error)
Without a registered error handler, exceptions log at ERROR level automatically.
Handler deregistration
client.off("GoalScored", my_handler)
client.off_any(my_handler)
# Fire once then auto-remove
client.once("MatchCreated", lambda msg: print("Match started"))
Logging
Use the standard logging module, no library-specific flags needed:
import logging
logging.getLogger("rlstatsapi").setLevel(logging.DEBUG)
StatsClient parameters
| Parameter | Default | Description |
|---|---|---|
host |
"127.0.0.1" |
TCP host |
port |
49123 |
TCP port |
reconnect |
True |
Auto-reconnect on drop |
reconnect_delay |
0.5 |
Initial reconnect delay (s) |
max_reconnect_delay |
30.0 |
Backoff cap (s) |
max_reconnect_attempts |
None |
Max retries (None = infinite) |
connect_timeout |
5.0 |
TCP connect timeout (s) |
include_raw |
False |
Include raw JSON string in EventMessage.raw |
queue_size |
2048 |
Internal event queue size |
overflow |
"block" |
Queue-full policy: "block" / "drop" / "raise" |
is_connected
print(client.is_connected) # True once TCP is established
Public API
Registration:
on(event_name, handler) · on_any(handler) · on_<event>(handler) · on_connect(handler) · on_disconnect(handler) · on_handler_error(handler)
Deregistration:
off(event_name, handler) · off_any(handler) · once(event_name, handler)
Lifecycle:
connect() · disconnect() · async with StatsClient()
Async iteration:
events() async iterator yielding EventMessage
Types:
EventName · TypedEventMessage[T] · KnownEventMessage · per-event payload types (GoalScoredPayload, UpdateStatePayload, …)
Notes
- Works for regular matches. Some fields like
MatchGuidare only present in online/LAN contexts. - In current builds this endpoint may behave as a plain TCP JSON stream instead of a WebSocket upgrade. This library handles the TCP stream format.
Disclaimer
This project is an independent, community-made library and is not affiliated with, endorsed by, or sponsored by Psyonix or Epic Games.
Rocket League and related trademarks are the property of their respective owners.
Use this library at your own risk and in compliance with Rocket League’s terms and policies.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rlstatsapi-0.1.3.tar.gz.
File metadata
- Download URL: rlstatsapi-0.1.3.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b98dbfb0c4c6b1bd60d8afe3520346bf27bf355b2a5d26d786345274957c545
|
|
| MD5 |
6ff859ec358557be0803a4652c87c3e2
|
|
| BLAKE2b-256 |
6d3d35a40300885a2d0336d3e8ecd6a02935ee1681a50d97df66ee140655d03a
|
File details
Details for the file rlstatsapi-0.1.3-py3-none-any.whl.
File metadata
- Download URL: rlstatsapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b772469f4f11ef237be004bdacb4946ad4e44620165db608f909bc1d8300b9
|
|
| MD5 |
a95df77de26fe89fa34ed50a22427222
|
|
| BLAKE2b-256 |
598d6a24f6dd42b20434683fa0eab7ebaeb993aef5649aaf47e75d92beaa5ea4
|