TypeScript

If you're using TypeScript, we publish @srating-io/types on npm — shared type definitions for the tables and endpoint responses used across srating.io, kept in sync with this API.

Install

npm install @srating-io/types

Usage

import type { General, Game } from '@srating-io/types';

const response = await fetch(
  'https://api.srating.io/v1/game/getGames?start_date=2023-04-03&organization_id=f1c37c98-3b4c-11ef-94bc-2a93761010b8&division_id=bf602dc4-3b4a-11ef-94bc-2a93761010b8',
  { headers: { 'X-API-KEY': 'YOUR_API_KEY' } }
);

const games: Game.getGamesResults = await response.json();

for (const game_id in games) {
  const game: General.Game = games[game_id];
  console.log(game.home_score, game.away_score);
}

Types are organized by sport (Basketball, Football) and by table (General), plus a few richer per-endpoint response types like Game.getGamesResults above, which also includes the nested odds and teams you see in the response example. Not every endpoint has one of these yet — most raw table rows are covered by General alone.

View the source on GitHub →

On this page