API Reference¶
rlstatsapi.client¶
Core async TCP client for Rocket League's live Stats exporter.
This module handles socket lifecycle, JSON stream framing, dispatching to user handlers, reconnect strategy, and queue backpressure behavior.
ConnectionState
¶
Bases: Enum
Granular connection lifecycle state for a StatsClient.
Source code in src/rlstatsapi/client.py
53 54 55 56 57 58 59 | |
StatsClient
¶
Event client for Rocket League Stats API.
Source code in src/rlstatsapi/client.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 | |
connection_state
property
¶
Return the current connection lifecycle state.
is_connected
property
¶
Return True if the client is currently connected to the Stats API.
last_error
property
¶
Return the latest connection or reader error seen by the background task.
metrics
property
¶
Return read-only-style counters for throughput and reconnect behavior.
permanently_failed
property
¶
Return True when reconnect attempts were exhausted.
state
property
¶
Return the latest convenience match snapshot derived from recent events.
__aenter__()
async
¶
Connect and return self for use as an async context manager.
Source code in src/rlstatsapi/client.py
163 164 165 166 | |
__aexit__(*_)
async
¶
Disconnect when leaving the async context manager.
Source code in src/rlstatsapi/client.py
168 169 170 | |
__init__(host='127.0.0.1', port=49123, reconnect=True, reconnect_delay=0.5, max_reconnect_delay=30.0, max_reconnect_attempts=None, include_raw=False, queue_size=2048, overflow='block', connect_timeout=5.0, drain_on_disconnect=False, handler_timeout=None)
¶
Configure the client.
Does not connect until connect() or async context manager entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Stats API host address. |
'127.0.0.1'
|
port
|
int
|
Stats API TCP port. |
49123
|
reconnect
|
bool
|
Whether to reconnect automatically on connection loss. |
True
|
reconnect_delay
|
float
|
Initial delay in seconds before the first reconnect attempt. |
0.5
|
max_reconnect_delay
|
float
|
Upper bound for exponential backoff delay. |
30.0
|
max_reconnect_attempts
|
int | None
|
Stop reconnecting after this many failures. None means unlimited. |
None
|
include_raw
|
bool
|
Attach the original JSON string to each |
False
|
queue_size
|
int
|
Max events buffered in the internal queue. |
2048
|
overflow
|
Literal['block', 'drop', 'raise']
|
Queue-full behavior |
'block'
|
connect_timeout
|
float
|
Seconds to wait for TCP handshake before raising. |
5.0
|
drain_on_disconnect
|
bool
|
Clear the queue when the session ends. |
False
|
handler_timeout
|
float | None
|
Max seconds an async handler may run before being cancelled. Sync handlers are not affected. None disables the timeout. |
None
|
Source code in src/rlstatsapi/client.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
clear_queue()
¶
Drop any queued events that have not been consumed yet.
Source code in src/rlstatsapi/client.py
541 542 543 544 545 546 547 | |
connect()
async
¶
Start the background reader task and begin connecting. No-op if already running.
Source code in src/rlstatsapi/client.py
172 173 174 175 176 177 178 179 180 181 182 | |
disconnect(timeout=5.0)
async
¶
Disconnect from the Stats API and stop the reader task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Seconds to wait for the reader task to finish before giving up. |
5.0
|
Source code in src/rlstatsapi/client.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
events(*event_names)
async
¶
Async iterator that yields incoming events, optionally filtered by name.
Source code in src/rlstatsapi/client.py
729 730 731 732 733 734 735 | |
off(event_name, handler)
¶
Unregister one handler for a specific event if present.
Source code in src/rlstatsapi/client.py
529 530 531 532 533 534 | |
off_any(handler)
¶
Unregister a global handler registered with on_any.
Source code in src/rlstatsapi/client.py
536 537 538 539 | |
on(event_name, handler=None)
¶
on(event_name: Literal['UpdateState'], handler: Callable[[TypedEventMessage[UpdateStatePayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['UpdateState']) -> Callable[[Callable[[TypedEventMessage[UpdateStatePayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[UpdateStatePayload]], Awaitable[None] | None]]
on(event_name: Literal['BallHit'], handler: Callable[[TypedEventMessage[BallHitPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['BallHit']) -> Callable[[Callable[[TypedEventMessage[BallHitPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[BallHitPayload]], Awaitable[None] | None]]
on(event_name: Literal['ClockUpdatedSeconds'], handler: Callable[[TypedEventMessage[ClockUpdatedSecondsPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['ClockUpdatedSeconds']) -> Callable[[Callable[[TypedEventMessage[ClockUpdatedSecondsPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[ClockUpdatedSecondsPayload]], Awaitable[None] | None]]
on(event_name: Literal['CountdownBegin'], handler: Callable[[TypedEventMessage[CountdownBeginPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['CountdownBegin']) -> Callable[[Callable[[TypedEventMessage[CountdownBeginPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[CountdownBeginPayload]], Awaitable[None] | None]]
on(event_name: Literal['CrossbarHit'], handler: Callable[[TypedEventMessage[CrossbarHitPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['CrossbarHit']) -> Callable[[Callable[[TypedEventMessage[CrossbarHitPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[CrossbarHitPayload]], Awaitable[None] | None]]
on(event_name: Literal['GoalReplayEnd'], handler: Callable[[TypedEventMessage[GoalReplayEndPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['GoalReplayEnd']) -> Callable[[Callable[[TypedEventMessage[GoalReplayEndPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[GoalReplayEndPayload]], Awaitable[None] | None]]
on(event_name: Literal['GoalReplayStart'], handler: Callable[[TypedEventMessage[GoalReplayStartPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['GoalReplayStart']) -> Callable[[Callable[[TypedEventMessage[GoalReplayStartPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[GoalReplayStartPayload]], Awaitable[None] | None]]
on(event_name: Literal['GoalReplayWillEnd'], handler: Callable[[TypedEventMessage[GoalReplayWillEndPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['GoalReplayWillEnd']) -> Callable[[Callable[[TypedEventMessage[GoalReplayWillEndPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[GoalReplayWillEndPayload]], Awaitable[None] | None]]
on(event_name: Literal['GoalScored'], handler: Callable[[TypedEventMessage[GoalScoredPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['GoalScored']) -> Callable[[Callable[[TypedEventMessage[GoalScoredPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[GoalScoredPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchCreated'], handler: Callable[[TypedEventMessage[MatchCreatedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchCreated']) -> Callable[[Callable[[TypedEventMessage[MatchCreatedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchCreatedPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchInitialized'], handler: Callable[[TypedEventMessage[MatchInitializedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchInitialized']) -> Callable[[Callable[[TypedEventMessage[MatchInitializedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchInitializedPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchDestroyed'], handler: Callable[[TypedEventMessage[MatchDestroyedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchDestroyed']) -> Callable[[Callable[[TypedEventMessage[MatchDestroyedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchDestroyedPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchEnded'], handler: Callable[[TypedEventMessage[MatchEndedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchEnded']) -> Callable[[Callable[[TypedEventMessage[MatchEndedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchEndedPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchPaused'], handler: Callable[[TypedEventMessage[MatchPausedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchPaused']) -> Callable[[Callable[[TypedEventMessage[MatchPausedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchPausedPayload]], Awaitable[None] | None]]
on(event_name: Literal['MatchUnpaused'], handler: Callable[[TypedEventMessage[MatchUnpausedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['MatchUnpaused']) -> Callable[[Callable[[TypedEventMessage[MatchUnpausedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[MatchUnpausedPayload]], Awaitable[None] | None]]
on(event_name: Literal['PodiumStart'], handler: Callable[[TypedEventMessage[PodiumStartPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['PodiumStart']) -> Callable[[Callable[[TypedEventMessage[PodiumStartPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[PodiumStartPayload]], Awaitable[None] | None]]
on(event_name: Literal['ReplayCreated'], handler: Callable[[TypedEventMessage[ReplayCreatedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['ReplayCreated']) -> Callable[[Callable[[TypedEventMessage[ReplayCreatedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[ReplayCreatedPayload]], Awaitable[None] | None]]
on(event_name: Literal['RoundStarted'], handler: Callable[[TypedEventMessage[RoundStartedPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['RoundStarted']) -> Callable[[Callable[[TypedEventMessage[RoundStartedPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[RoundStartedPayload]], Awaitable[None] | None]]
on(event_name: Literal['StatfeedEvent'], handler: Callable[[TypedEventMessage[StatfeedEventPayload]], Awaitable[None] | None]) -> None
on(event_name: Literal['StatfeedEvent']) -> Callable[[Callable[[TypedEventMessage[StatfeedEventPayload]], Awaitable[None] | None]], Callable[[TypedEventMessage[StatfeedEventPayload]], Awaitable[None] | None]]
on(event_name: str, handler: Handler) -> None
on(event_name: str) -> Callable[[Handler], Handler]
Register a handler for an event or return a decorator form of registration.
Source code in src/rlstatsapi/client.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
on_any(handler)
¶
Register a handler that runs for every incoming event.
Source code in src/rlstatsapi/client.py
520 521 522 | |
on_ball_hit(handler)
¶
Typed helper for registering BallHit handlers.
Source code in src/rlstatsapi/client.py
569 570 571 572 573 574 | |
on_clock_updated_seconds(handler)
¶
Typed helper for registering ClockUpdatedSeconds handlers.
Source code in src/rlstatsapi/client.py
576 577 578 579 580 581 582 583 | |
on_connect(handler)
¶
Register a callback fired after TCP connection is established.
Source code in src/rlstatsapi/client.py
209 210 211 | |
on_countdown_begin(handler)
¶
Typed helper for registering CountdownBegin handlers.
Source code in src/rlstatsapi/client.py
585 586 587 588 589 590 591 592 | |
on_crossbar_hit(handler)
¶
Typed helper for registering CrossbarHit handlers.
Source code in src/rlstatsapi/client.py
594 595 596 597 598 599 600 601 | |
on_disconnect(handler)
¶
Register a callback fired when the active TCP session is closed.
Source code in src/rlstatsapi/client.py
213 214 215 | |
on_goal_replay_end(handler)
¶
Typed helper for registering GoalReplayEnd handlers.
Source code in src/rlstatsapi/client.py
603 604 605 606 607 608 609 610 | |
on_goal_replay_start(handler)
¶
Typed helper for registering GoalReplayStart handlers.
Source code in src/rlstatsapi/client.py
612 613 614 615 616 617 618 619 | |
on_goal_replay_will_end(handler)
¶
Typed helper for registering GoalReplayWillEnd handlers.
Source code in src/rlstatsapi/client.py
621 622 623 624 625 626 627 628 | |
on_goal_scored(handler)
¶
Typed helper for registering GoalScored handlers.
Source code in src/rlstatsapi/client.py
630 631 632 633 634 635 636 637 | |
on_handler_error(handler)
¶
Register a callback for exceptions raised inside event handlers.
Source code in src/rlstatsapi/client.py
217 218 219 | |
on_many(event_names, handler)
¶
Register the same handler for several event names in one call.
Source code in src/rlstatsapi/client.py
524 525 526 527 | |
on_match_created(handler)
¶
Typed helper for registering MatchCreated handlers.
Source code in src/rlstatsapi/client.py
639 640 641 642 643 644 645 646 | |
on_match_destroyed(handler)
¶
Typed helper for registering MatchDestroyed handlers.
Source code in src/rlstatsapi/client.py
657 658 659 660 661 662 663 664 | |
on_match_ended(handler)
¶
Typed helper for registering MatchEnded handlers.
Source code in src/rlstatsapi/client.py
666 667 668 669 670 671 672 673 | |
on_match_initialized(handler)
¶
Typed helper for registering MatchInitialized handlers.
Source code in src/rlstatsapi/client.py
648 649 650 651 652 653 654 655 | |
on_match_paused(handler)
¶
Typed helper for registering MatchPaused handlers.
Source code in src/rlstatsapi/client.py
675 676 677 678 679 680 681 682 | |
on_match_unpaused(handler)
¶
Typed helper for registering MatchUnpaused handlers.
Source code in src/rlstatsapi/client.py
684 685 686 687 688 689 690 691 | |
on_podium_start(handler)
¶
Typed helper for registering PodiumStart handlers.
Source code in src/rlstatsapi/client.py
693 694 695 696 697 698 699 700 | |
on_replay_created(handler)
¶
Typed helper for registering ReplayCreated handlers.
Source code in src/rlstatsapi/client.py
702 703 704 705 706 707 708 709 | |
on_round_started(handler)
¶
Typed helper for registering RoundStarted handlers.
Source code in src/rlstatsapi/client.py
711 712 713 714 715 716 717 718 | |
on_statfeed_event(handler)
¶
Typed helper for registering StatfeedEvent handlers.
Source code in src/rlstatsapi/client.py
720 721 722 723 724 725 726 727 | |
on_update_state(handler)
¶
Typed helper for registering UpdateState handlers.
Source code in src/rlstatsapi/client.py
560 561 562 563 564 565 566 567 | |
once(event_name, handler)
¶
Register a handler that runs once and removes itself automatically.
Source code in src/rlstatsapi/client.py
549 550 551 552 553 554 555 556 557 558 | |
wait_for(event_name, *, timeout=None)
async
¶
Wait until the next occurrence of event_name and return the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
The event to wait for (e.g. |
required |
timeout
|
float | None
|
Seconds before raising |
None
|
Returns:
| Type | Description |
|---|---|
EventMessage
|
The first matching |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If |
Source code in src/rlstatsapi/client.py
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
rlstatsapi.config¶
Helpers for reading and updating Rocket League's TAStatsAPI.ini.
This module keeps file management separate from the network client so users can
prepare the game config before starting Rocket League and then connect with
StatsClient using the same port.
StatsAPIConfigStatus
dataclass
¶
Snapshot of the current Stats API config file state.
Source code in src/rlstatsapi/config.py
27 28 29 30 31 32 33 34 35 36 37 | |
candidate_stats_api_paths()
¶
Return likely user config locations for TAStatsAPI.ini on Windows.
Source code in src/rlstatsapi/config.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
configure_stats_api(enabled, port=DEFAULT_STATS_API_PORT, packet_send_rate=DEFAULT_PACKET_SEND_RATE, path=None)
¶
Set PacketSendRate and Port together in one write operation.
Source code in src/rlstatsapi/config.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
find_stats_api_config(path=None)
¶
Resolve an explicit config path or the first matching auto-discovered path.
Source code in src/rlstatsapi/config.py
83 84 85 86 87 88 89 90 91 92 | |
get_stats_api_status(path=None)
¶
Read the current enabled state, send rate, and port from the config file.
Source code in src/rlstatsapi/config.py
95 96 97 98 99 100 101 102 103 104 105 106 107 | |
set_stats_api_enabled(enabled, packet_send_rate=DEFAULT_PACKET_SEND_RATE, path=None)
¶
Write PacketSendRate and preserve the current port.
Source code in src/rlstatsapi/config.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
set_stats_api_port(port, path=None)
¶
Write the local TCP port used by Rocket League's stats exporter.
Source code in src/rlstatsapi/config.py
131 132 133 134 135 136 137 138 139 140 141 142 143 | |
rlstatsapi.models¶
Runtime envelopes used by the streaming client.
These are lightweight transport models (not validators) used while events move through internal queues and user callbacks.
ClientMetrics
dataclass
¶
Mutable counters that summarize client throughput and reconnect behavior.
Source code in src/rlstatsapi/models.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
reset()
¶
Reset all counters and update started_at to now.
Source code in src/rlstatsapi/models.py
46 47 48 49 50 51 52 53 54 | |
EventMessage
dataclass
¶
Normalized Rocket League Stats API message envelope.
Source code in src/rlstatsapi/models.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
as_type(event_name)
¶
Return this message with event-specific payload typing for editors/type-checkers.
Source code in src/rlstatsapi/models.py
24 25 26 27 28 29 30 31 | |
MatchStateSnapshot
dataclass
¶
Summary of the latest match state seen from incoming events.
Source code in src/rlstatsapi/models.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
PlayerSnapshot
dataclass
¶
Per-player state extracted from the latest UpdateState event.
Source code in src/rlstatsapi/models.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
rlstatsapi.state¶
Lightweight helpers for tracking a match summary from the live event stream.
The goal here is convenience, not full replay-state reconstruction. The tracker keeps the handful of fields that most HUDs, overlays, bots, and dashboards want without forcing users to rebuild the same state cache in every script.
MatchStateTracker
¶
Maintain a rolling summary of the latest match state seen by the client.
Source code in src/rlstatsapi/state.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
snapshot
property
¶
Return the mutable snapshot object updated by incoming events.
reset()
¶
Clear the current snapshot when a match ends or the caller wants a reset.
Source code in src/rlstatsapi/state.py
25 26 27 | |
update(message)
¶
Apply one incoming event and return the updated snapshot.
Source code in src/rlstatsapi/state.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
rlstatsapi.types¶
Static typing layer for documented Rocket League event payloads.
TypedDicts here mirror the official event schema and are designed for IDE autocomplete and type-checking, without adding runtime parsing overhead.
TypedEventMessage
dataclass
¶
Bases: Generic[TData]
Typed event envelope used by helpers and typed convenience callbacks.
Source code in src/rlstatsapi/types.py
258 259 260 261 262 263 264 | |
cast_event_data(event_name, data)
¶
cast_event_data(event_name: Literal['UpdateState'], data: Mapping[str, Any]) -> UpdateStatePayload
cast_event_data(event_name: Literal['BallHit'], data: Mapping[str, Any]) -> BallHitPayload
cast_event_data(event_name: Literal['ClockUpdatedSeconds'], data: Mapping[str, Any]) -> ClockUpdatedSecondsPayload
cast_event_data(event_name: Literal['CountdownBegin'], data: Mapping[str, Any]) -> CountdownBeginPayload
cast_event_data(event_name: Literal['CrossbarHit'], data: Mapping[str, Any]) -> CrossbarHitPayload
cast_event_data(event_name: Literal['GoalReplayEnd'], data: Mapping[str, Any]) -> GoalReplayEndPayload
cast_event_data(event_name: Literal['GoalReplayStart'], data: Mapping[str, Any]) -> GoalReplayStartPayload
cast_event_data(event_name: Literal['GoalReplayWillEnd'], data: Mapping[str, Any]) -> GoalReplayWillEndPayload
cast_event_data(event_name: Literal['GoalScored'], data: Mapping[str, Any]) -> GoalScoredPayload
cast_event_data(event_name: Literal['MatchCreated'], data: Mapping[str, Any]) -> MatchCreatedPayload
cast_event_data(event_name: Literal['MatchInitialized'], data: Mapping[str, Any]) -> MatchInitializedPayload
cast_event_data(event_name: Literal['MatchDestroyed'], data: Mapping[str, Any]) -> MatchDestroyedPayload
cast_event_data(event_name: Literal['MatchEnded'], data: Mapping[str, Any]) -> MatchEndedPayload
cast_event_data(event_name: Literal['MatchPaused'], data: Mapping[str, Any]) -> MatchPausedPayload
cast_event_data(event_name: Literal['MatchUnpaused'], data: Mapping[str, Any]) -> MatchUnpausedPayload
cast_event_data(event_name: Literal['PodiumStart'], data: Mapping[str, Any]) -> PodiumStartPayload
cast_event_data(event_name: Literal['ReplayCreated'], data: Mapping[str, Any]) -> ReplayCreatedPayload
cast_event_data(event_name: Literal['RoundStarted'], data: Mapping[str, Any]) -> RoundStartedPayload
cast_event_data(event_name: Literal['StatfeedEvent'], data: Mapping[str, Any]) -> StatfeedEventPayload
cast_event_data(event_name: str, data: Mapping[str, Any]) -> Mapping[str, Any]
Type-only helper to narrow data based on event name.
Source code in src/rlstatsapi/types.py
388 389 390 391 392 | |