slapshot.ts

Unofficial “Slapshot: Rebound” API Wrapper

This API wrapper is written in TypeScript using axios. It wraps the Slapshot: Rebound Public API, which is documented here.

Table of Contents

Installation

npm install slapshot.ts

Example Usage

import Slapshot from 'slapshot.ts';

const slapshot = new Slapshot({ key: 'your api key' });

async function main(): Promise<void> {
  const game = await slapshot.getGame('game id');
  console.log(game);
}

main();

Interfaces

API Options

interface Options {
  key   : string; // API key provided by Slapshot Rebound
  env ? : string; // API environment, defaults to 'api'. Can be 'staging'.
}

Enums

Enums provide predefined lists of values used throughout the API. They help standardize inputs and outputs across the methods.

API

// Get all available API environments
Slapshot.environments;

Example Usage

const environments = Slapshot.environments;
console.log(environments); // ['api', 'staging']

Game

Slapshot.gameModes;

Example Usage

const gameModes = Slapshot.gameModes;
console.log(gameModes); // ['hockey', 'dodgepuck', 'tag']
Slapshot.regions;

Example Usage

const regions = Slapshot.regions;
console.log(regions); // ['eu-west', 'na-east', 'na-central', 'na-west', 'oce-east']
Slapshot.arenas;

Example Usage

const arenas = Slapshot.arenas;
console.log(arenas); // ['Slapstadium', 'Slapville', 'Colosseum', ...]
Slapshot.endReasons;

Example Usage

const endReasons = Slapshot.endReasons;
console.log(endReasons); // ['EndOfRegulation', 'Overtime', 'MercyRule', ...]

Cosmetics

Slapshot.cosmeticTypes;

Example Usage

const cosmeticTypes = Slapshot.cosmeticTypes;
console.log(cosmeticTypes); // {'Hat', 'Gloves', 'Stick', ...}
Slapshot.cosmeticRarities;

Example Usage

const cosmeticRarities = Slapshot.cosmeticRarities;
console.log(cosmeticRarities); // {'Common', 'Rare', 'Epic', 'Legendary'}

Methods

This section covers the different API methods available through this wrapper.

Matchmaking

// Get the current matchmaking queue
await getMatchmakingQueue(regions?: string[]): Promise<any>;

Parameters:

Example Usage

const matchmakingQueue = await slapshot.getMatchmakingQueue(['na-west']);
console.log(matchmakingQueue);

Game

// Get game details by ID
await getGame(gameId: string): Promise<any>;

Parameters:

Example Usage

const game = await slapshot.getGame('game-id');
console.log(game);

Lobby

// Get a lobby by ID
await getLobby(lobbyId: string): Promise<any>;

Example Usage

const lobby = await slapshot.getLobby('lobby-id');
console.log(lobby);
// Get all matches in a lobby
await getLobbyMatches(lobbyId: string): Promise<any>;

Example Usage

const matches = await slapshot.getLobbyMatches('lobby-id');
console.log(matches);
// Create a new lobby
await createLobby(lobbyCreationRequest: LobbyCreationRequest): Promise<any>;

Example Usage

const lobbyCreationRequest = {
  name: 'New Lobby',
  password: 'secret',
};
const newLobby = await slapshot.createLobby(lobbyCreationRequest);
console.log(newLobby);

Player

// Get a player's outfit by player ID
await getPlayerOutfit(playerId: string): Promise<any>;

Example Usage

const outfit = await slapshot.getPlayerOutfit('player-id');
console.log(outfit);
// Get a Slapshot player ID from a Steam ID
await steamIDtoSlapshotID(steamId: string): Promise<any>;

Example Usage

const slapshotID = await slapshot.steamIDtoSlapshotID('steam-id');
console.log(slapshotID);

Shop / Cosmetics

// Get the current shop
await getShop(): Promise<any>;

Example Usage

const shop = await slapshot.getShop();
console.log(shop);