export declare namespace Commands { namespace ChangePov { type Focus = "Ball" | `${number}`; type Perspective = "Fly" | "SoftAttach" | "HardAttach" | "PlayerView" | "AutoCam" | "Camera_Director"; } } export interface BaseMessage { Event: Events.AllEventNames; Data: string; } export interface Vector { X: number; Y: number; Z: number; } export interface Player { /** Display name. */ Name: string; /** Platform identifier in the format Platform|Uid|Splitscreen (e.g. "Steam|123|0", "Epic|456|0"). */ PrimaryId: string; /** Spectator shortcut number. */ Shortcut: number; /** Team index (0 = Blue, 1 = Orange). */ TeamNum: number; /** Total match score. */ Score: number; /** Goals scored this match. */ Goals: number; /** Shot attempts this match. */ Shots: number; /** Assists earned this match. */ Assists: number; /** Saves made this match. */ Saves: number; /** Total ball touches. */ Touches: number; /** Touches by the car body (not ball). */ CarTouches: number; /** Demolitions inflicted. */ Demos: number; /** Asset names of the equipped loadout for the player's current team sorted by product slot. */ Loadout: string[]; /** * True if the player currently has a vehicle. * @SPECTATOR */ bHasCar: boolean; /** * Vehicle speed in Unreal Units/second. * @SPECTATOR */ Speed: number; /** * Boost amount 0–100. * @SPECTATOR */ Boost: number; /** * True if the player is currently boosting. * @SPECTATOR */ bBoosting?: boolean; /** * True if at least 3 wheels are touching the world. * @SPECTATOR */ bOnGround?: boolean; /** * True if the vehicle is on a wall. * @SPECTATOR */ bOnWall?: boolean; /** * True if the player is holding handbrake. * @SPECTATOR */ bPowersliding?: boolean; /** * True if the vehicle is currently destroyed. * @SPECTATOR */ bDemolished?: boolean; /** * True if the vehicle is at supersonic speed. * @SPECTATOR */ bSupersonic?: boolean; /** * Class name of the player's currently available Rumble pickup. Omitted when not playing with rumble powerups. * @SPECTATOR */ PickupClass?: string; /** * The player who demolished this player. Present only when demolished. */ Attacker?: PlayerRef; } export type PlayerRef = Pick; export interface BallLastTouch { /** The player who made the last touch. */ Player: PlayerRef; /** Speed of the ball resulting from this hit. */ Speed: number; } export declare namespace Events { export type AllEventNames = "UpdateState" | "BallHit" | "BoostPickup" | "ClockUpdatedSeconds" | "CountdownBegin" | "CrossbarHit" | "GoalReplayStart" | "GoalReplayWillEnd" | "GoalReplayEnd" | "GoalScored" | "MatchCreated" | "MatchInitialized" | "MatchPaused" | "MatchUnpaused" | "MatchEnded" | "MatchDestroyed" | "PlayerJoined" | "PlayerLeft" | "PodiumStart" | "ReplayCreated" | "RoundStarted" | "StatfeedEvent"; interface EventBase { /** Only set for online or LAN matches. */ MatchGuid: string; } export namespace Partials_UpdateState { interface GameTeam { /** Team name. */ Name: string; /** Team index. */ TeamNum: number; /** Team goal count. */ Score: number; /** * Hex color code (no #) for the team’s primary color. * @example "FF9F00" */ ColorPrimary: string; /** Hex color code for the team’s secondary color. * @example "E5E5E5" */ ColorSecondary: string; } interface GameBall { /** Current ball speed in Unreal Units/second. */ Speed: number; /** Index of the last team to touch the ball. `255` if the ball has not been touched. */ TeamNum: number; } /** * Match metadata. */ interface Game { /** One entry per team, ordered by TeamNum. */ Teams: GameTeam[]; /** Playlist Id of the current match. */ PlaylistId: number; /** Seconds remaining in the match. */ TimeSeconds: number; /** True if the match is in overtime. */ bOvertime: boolean; /** Current ball state. */ Ball: GameBall; /** True if a goal replay or history replay is active. */ bReplay: boolean; /** True if a team has won. */ bHasWinner: boolean; /** Name of the winning team. Empty string if no winner yet. */ Winner: string; /** Asset name of the current map (e.g. "Stadium_P"). * @example "Wasteland_GRS_P" */ Arena: string; /** True if the client is currently viewing a specific vehicle. */ bHasTarget: boolean; /** Player currently being viewed. Members are an empty string or 0 if the player does not have a spectator target. */ Target?: PlayerRef; /** Current frame number if a replay is active. */ Frame?: number; /** Seconds elapsed since game start if a replay is active. */ Elapsed?: number; } } /** * Sent X amount of times per second based on the player's PacketSendRate preference. */ export interface Event_UpdateState extends EventBase { /** One entry per player in the match. */ Players: Player[]; /** Match metadata. */ Game: Partials_UpdateState.Game; } export namespace Partials_BallHit { interface Ball { /** Ball speed before the hit (Unreal Units/second). */ PreHitSpeed: number; /** Ball speed after the hit (Unreal Units/second). */ PostHitSpeed: number; /** World position of the ball at impact. */ Location: Vector; } } export interface Event_BallHit extends EventBase { /** Players that hit the ball that frame. */ Players: PlayerRef[]; /** Ball state at the moment of the hit. */ Ball: Partials_BallHit.Ball; } export interface Event_BoostPickup extends EventBase { /** The player who collected the boost. */ Player: PlayerRef; /** World location of the pickup. */ Location: Vector; /** Amount of boost granted by the pickup. */ BoostAmount: number; /** Pickup class: BoostType_Pad (small pad), BoostType_Pill (full/big boost). */ BoostType: "BoostType_Pad" | "BoostType_Pill"; /** True if the pickup occurred during replay playback. */ bReplay: boolean; } export interface Event_ClockUpdatedSeconds extends EventBase { /** Seconds remaining in the match. */ TimeSeconds: number; /** True if the game is in overtime. */ bOvertime: boolean; } export interface Event_CountdownBegin extends EventBase { } export interface Event_CrossbarHit extends EventBase { /** Ball speed on impact. */ BallSpeed: number; /** Impact force of the ball relative to the crossbar normal. */ ImpactForce: number; /** The last touch of the ball before the crossbar hit. */ BallLastTouch: BallLastTouch; /** World position of the ball when the impact occurred. */ BallLocation: Vector; } export interface Event_GoalReplayStart extends EventBase { } export interface Event_GoalReplayWillEnd extends EventBase { } export interface Event_GoalReplayEnd extends EventBase { } export interface Event_GoalScored extends EventBase { /** Speed of the ball (Unreal Units/second) when it crossed the goal line. */ GoalSpeed: number; /** Length of the previous round in seconds. */ GoalTime: number; /** World position of the ball when the goal was scored. */ ImpactLocation: Vector; /** The player who scored the goal. */ Scorer: PlayerRef; /** The last touch of the ball before the goal. */ BallLastTouch: BallLastTouch; /** Present only when an assist was recorded. */ Assister?: PlayerRef; } export interface Event_MatchCreated extends EventBase { } export interface Event_MatchInitialized extends EventBase { } export interface Event_MatchPaused extends EventBase { } export interface Event_MatchUnpaused extends EventBase { } export interface Event_MatchEnded extends EventBase { /** Team index of the winning team. */ WinnerTeamNum: number; } export interface Event_MatchDestroyed extends EventBase { } export interface Event_PlayerJoined extends EventBase { /** Display name of the player who joined. */ PlayerName: string; /** Platform identifier in the format Platform|Uid|Splitscreen (e.g. "Steam|123|0", "Epic|456|0"). */ PrimaryId: string; } export interface Event_PlayerLeft extends EventBase { /** Display name of the player who left. */ PlayerName: string; /** Platform identifier in the format Platform|Uid|Splitscreen (e.g. "Steam|123|0", "Epic|456|0"). */ PrimaryId: string; } export interface Event_PodiumStart extends EventBase { } export interface Event_ReplayCreated extends EventBase { /** File name of the replay. */ FileName: string; /** Timestamp the replay was created. */ Date: string; } export interface Event_RoundStarted extends EventBase { } export interface Event_StatfeedEvent extends EventBase { /** * Asset name of the StatEvent (e.g. "Demolish", "Save"). */ EventName: "Demolish" | "Demolition" | "Goal" | "Win" | "MVP" | "AerialGoal" | "BackwardsGoal" | "BicycleGoal" | "LongGoal" | "TurtleGoal" | "PoolShot" | "OvertimeGoal" | "HatTrick" | "Assist" | "Playmaker" | "Save" | "EpicSave" | "Savior" | "Shot" | "Center" | "Clear" | "FirstTouch" | "BreakoutDamage" | "BreakoutDamageLarge" | "LowFive" | "HighFive" | "HoopsSwishGoal" | "BicycleHit" | "OwnGoal" | "FlipReset"; /** * Localized display label for the stat (e.g. "Demolition"). */ Type: string; /** Player who earned the stat. */ MainTarget: PlayerRef; /** Player involved in the stat (e.g. the demolished player). */ SecondaryTarget?: PlayerRef; } export {}; } export declare class ConnectionError extends Error { } export declare class Connection { ws: WebSocket; onOpen?: (e: Event) => void; onMessage?: (event: Events.AllEventNames, dataStr: string) => void; onClose?: (e: CloseEvent) => void; onError?: (err: ConnectionError) => void; constructor(host: string, port: number, secure: boolean); handleMessage(e: MessageEvent): void; protected handleError(error: Error): void; protected handleError(message: string, errorOptions?: ErrorOptions): void; removeListeners(): void; close(): void; isConnected(): boolean; send(message: object): void; } export declare class ClientError extends Error { } export interface ClientOptions { /** * Hostname to connect to the Rocket League client. * @default '127.0.0.1' */ host: string; /** * Port to connect to the Rocket League client. * @default 49124 */ port: number; /** * Whether to use the wss: (true) or ws: (false) protocol. * @default false */ secure: boolean; } /** * @see https://www.rocketleague.com/developer/stats-api */ declare class Client { /** * Client options to use when connecting, etc. Recommended to configure with the constructor initially. */ options: ClientOptions; socket?: Connection; protected reconnectAttempts: number; protected reconnectTimeout: Parameters[0]; protected wasCloseCalled: boolean; /** * A lifecycle event for when the socket is successfully connected. */ onSocketConnected?: () => void; /** * A lifecycle event for when the socket is closed. */ onSocketClosed?: (event: { wasCloseCalled: boolean; }) => void; /** Emitted for any internal errors. */ onError?: (err: Error) => void; /** All events received on the socket except for UpdateState (tick event). */ onEvent?: (event: Events.AllEventNames, data: object) => void; /** * Sent X amount of times per second based on the player's PacketSendRate preference. * @see https://www.rocketleague.com/developer/stats-api#UpdateState */ onUpdateState?: (data: Events.Event_UpdateState) => void; /** * Sent one frame after the ball is hit. * @see https://www.rocketleague.com/developer/stats-api#BallHit */ onBallHit?: (data: Events.Event_BallHit) => void; /** * Sent when a vehicle collects a boost pad or pill. * @SPECTATOR * @see https://www.rocketleague.com/developer/stats-api#BoostPickup */ onBoostPickup?: (data: Events.Event_BoostPickup) => void; /** * Sent when the in-game clock has changed. * @SPECTATOR * @see https://www.rocketleague.com/developer/stats-api#ClockUpdatedSeconds */ onClockUpdatedSeconds?: (data: Events.Event_ClockUpdatedSeconds) => void; /** * Sent at the start of each round when the countdown starts. * @see https://www.rocketleague.com/developer/stats-api#CountdownBegin */ onCountdownBegin?: (data: Events.Event_CountdownBegin) => void; /** * Sent when the ball hits a crossbar. * @see https://www.rocketleague.com/developer/stats-api#CrossbarHit */ onCrossbarHit?: (data: Events.Event_CrossbarHit) => void; /** * Sent when a goal replay starts. * @see https://www.rocketleague.com/developer/stats-api#GoalReplayStart */ onGoalReplayStart?: (data: Events.Event_GoalReplayStart) => void; /** * Sent when a goal replay ends. * @see https://www.rocketleague.com/developer/stats-api#GoalReplayWillEnd */ onGoalReplayWillEnd?: (data: Events.Event_GoalReplayWillEnd) => void; /** * Sent when the ball explodes during a goal replay. If the replay is skipped this event will not fire. * @see https://www.rocketleague.com/developer/stats-api#GoalReplayEnd */ onGoalReplayEnd?: (data: Events.Event_GoalReplayEnd) => void; /** * Sent when a goal is scored. * @see https://www.rocketleague.com/developer/stats-api#GoalScored */ onGoalScored?: (data: Events.Event_GoalScored) => void; /** * Sent when all teams are created and replicated. * @see https://www.rocketleague.com/developer/stats-api#MatchCreated */ onMatchCreated?: (data: Events.Event_MatchCreated) => void; /** * Sent when the first countdown starts. * @see https://www.rocketleague.com/developer/stats-api#MatchInitialized */ onMatchInitialized?: (data: Events.Event_MatchInitialized) => void; /** * Sent when the game is paused by a match admin. * @see https://www.rocketleague.com/developer/stats-api#MatchPaused */ onMatchPaused?: (data: Events.Event_MatchPaused) => void; /** * Sent when the game is unpaused by a match admin. * @see https://www.rocketleague.com/developer/stats-api#MatchUnpaused */ onMatchUnpaused?: (data: Events.Event_MatchUnpaused) => void; /** * Sent when the match ends and a winner is chosen. * @see https://www.rocketleague.com/developer/stats-api#MatchUnpaused */ onMatchEnded?: (data: Events.Event_MatchEnded) => void; /** * Sent when leaving the game. * @see https://www.rocketleague.com/developer/stats-api#MatchDestroyed */ onMatchDestroyed?: (data: Events.Event_MatchDestroyed) => void; /** * Sent when a player is added to the current match. * @see https://www.rocketleague.com/developer/stats-api#PlayerJoined */ onPlayerJoined?: (data: Events.Event_PlayerJoined) => void; /** * Sent when a player is removed from the current match. * @see https://www.rocketleague.com/developer/stats-api#PlayerLeft */ onPlayerLeft?: (data: Events.Event_PlayerLeft) => void; /** * Sent when the game enters the podium state after the match ends. * @see https://www.rocketleague.com/developer/stats-api#PodiumStart */ onPodiumStart?: (data: Events.Event_PodiumStart) => void; /** * Sent when a replay is initialized. Does not pertain to goal replays, * only replays you load via the Match History menu. * @see https://www.rocketleague.com/developer/stats-api#ReplayCreated */ onReplayCreated?: (data: Events.Event_ReplayCreated) => void; /** * Sent when the game enters the active state (after the countdown finishes). * @see https://www.rocketleague.com/developer/stats-api#RoundStarted */ onRoundStarted?: (data: Events.Event_RoundStarted) => void; /** * Sent when someone earns a stat. * @see https://www.rocketleague.com/developer/stats-api#StatfeedEvent */ onStatfeedEvent?: (data: Events.Event_StatfeedEvent) => void; constructor(opts?: Partial); protected handleOpen(): void; protected handleClose(): void; protected handleError(error: Error): void; protected handleError(message: string, errorOptions?: ErrorOptions): void; protected handleMessage(event: Events.AllEventNames, dataStr: string): void; protected sendCommand(command: string, data: object): void; /** * Connect to the Rocket League client. Will ignore subsequent calls to connect if already connected. */ connect(): void; /** * Close to connection to the Rocket League client. Will ignore subsequent calls to close. */ close(): void; /** * Tests if the client has a socket that is open. */ isConnected(): this is { socket: Connection; }; /** * Changes the spectator/replay viewpoint. At least one of Focus or Perspective must be supplied; both may be combined. * @SPECTATOR * @REPLAY * @param opts.focus What to look at -- the ball or a specific player. * @param opts.perspective Camera mode to switch to. * @see https://www.rocketleague.com/developer/stats-api#ChangePOV */ changePov(opts: Partial<{ focus: Commands.ChangePov.Focus; perspective: Commands.ChangePov.Perspective; }>): void; /** * Loads and begins playback of a replay by file name or by file path. * @param opts.fileName Name of the replay file to play. Takes precedence over Path when both are set. * @param opts.path File path of a replay to play. Used when FileName is empty. * @see https://www.rocketleague.com/developer/stats-api#LoadReplay */ loadReplay(opts: Partial<{ fileName: string; path: string; }>): void; /** * Jumps replay playback to a target frame or time. * @REPLAY * @param opts.frame Target frame number. Takes precedence over timeSeconds when set. * @param opts.timeSeconds Target time in seconds. * @see https://www.rocketleague.com/developer/stats-api#SeekReplay */ seekReplay(opts: Partial<{ frame: number; timeSeconds: number; }>): void; /** * Sets replay playback speed. * @REPLAY * @param speed Playback multiplier. 1.0 = normal, 0.5 = half speed, 2.0 = double. Must be ≥ 0. * @see https://www.rocketleague.com/developer/stats-api#SetGameSpeed */ setGameSpeed(speed: number): void; /** * Shows or hides the in-game HUD. * @param visible true shows the HUD; false hides it. * @see https://www.rocketleague.com/developer/stats-api#SetHUDVisibility */ setHudVisibility(visible: boolean): void; /** * Pauses or unpauses the current match or replay. * @param paused true pauses; false resumes. * @see https://www.rocketleague.com/developer/stats-api#SetMatchPaused */ setMatchPaused(paused: boolean): void; } export { Client as default, }; export {};