This API wrapper is written in TypeScript using axios. It wraps the Slapshot: Rebound Public API, which is documented here.
npm install slapshot.ts
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();
interface Options {
key : string; // API key provided by Slapshot Rebound
env ? : string; // API environment, defaults to 'api'. Can be 'staging'.
}
Enums provide predefined lists of values used throughout the API. They help standardize inputs and outputs across the methods.
// Get all available API environments
Slapshot.environments;
const environments = Slapshot.environments;
console.log(environments); // ['api', 'staging']
Slapshot.gameModes;
const gameModes = Slapshot.gameModes;
console.log(gameModes); // ['hockey', 'dodgepuck', 'tag']
Slapshot.regions;
const regions = Slapshot.regions;
console.log(regions); // ['eu-west', 'na-east', 'na-central', 'na-west', 'oce-east']
Slapshot.arenas;
const arenas = Slapshot.arenas;
console.log(arenas); // ['Slapstadium', 'Slapville', 'Colosseum', ...]
Slapshot.endReasons;
const endReasons = Slapshot.endReasons;
console.log(endReasons); // ['EndOfRegulation', 'Overtime', 'MercyRule', ...]
Slapshot.cosmeticTypes;
const cosmeticTypes = Slapshot.cosmeticTypes;
console.log(cosmeticTypes); // {'Hat', 'Gloves', 'Stick', ...}
Slapshot.cosmeticRarities;
const cosmeticRarities = Slapshot.cosmeticRarities;
console.log(cosmeticRarities); // {'Common', 'Rare', 'Epic', 'Legendary'}
This section covers the different API methods available through this wrapper.
// Get the current matchmaking queue
await getMatchmakingQueue(regions?: string[]): Promise<any>;
regions
: An optional array of region strings (e.g., ['na-west', 'eu-west']
).const matchmakingQueue = await slapshot.getMatchmakingQueue(['na-west']);
console.log(matchmakingQueue);
// Get game details by ID
await getGame(gameId: string): Promise<any>;
gameId
: The unique identifier for the game.const game = await slapshot.getGame('game-id');
console.log(game);
// Get a lobby by ID
await getLobby(lobbyId: string): Promise<any>;
const lobby = await slapshot.getLobby('lobby-id');
console.log(lobby);
// Get all matches in a lobby
await getLobbyMatches(lobbyId: string): Promise<any>;
const matches = await slapshot.getLobbyMatches('lobby-id');
console.log(matches);
// Create a new lobby
await createLobby(lobbyCreationRequest: LobbyCreationRequest): Promise<any>;
const lobbyCreationRequest = {
name: 'New Lobby',
password: 'secret',
};
const newLobby = await slapshot.createLobby(lobbyCreationRequest);
console.log(newLobby);
// Get a player's outfit by player ID
await getPlayerOutfit(playerId: string): Promise<any>;
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>;
const slapshotID = await slapshot.steamIDtoSlapshotID('steam-id');
console.log(slapshotID);
// Get the current shop
await getShop(): Promise<any>;
const shop = await slapshot.getShop();
console.log(shop);