phc-nhl-api
Version:
Utility methods and models to call the NHL API
321 lines (315 loc) • 9.42 kB
TypeScript
type DisplayValue = {
default: string;
};
type Boxscore = {
id: number;
season: number;
gameType: number;
limitedScoring: boolean;
gameDate: string;
venue: DisplayValue;
venueLocation: DisplayValue;
startTimeUTC: string;
easternUTCOffset: string;
venueUTCOffset: string;
tvBroadcasts: {
id: number;
market: string;
countryCode: string;
network: string;
sequenceNumber: number;
}[];
gameState: string;
gameScheduleState: string;
periodDescriptor: {
number: number;
periodType: string;
};
regPeriods: number;
awayTeam: {
id: number;
name: DisplayValue;
abbrev: string;
score: number;
sog: number;
logo: string;
placeName: {
default: string;
};
};
homeTeam: {
id: number;
name: DisplayValue;
abbrev: string;
score: number;
sog: number;
logo: string;
placeName: {
default: string;
};
};
clock: {
timeRemaining: string;
secondsRemaining: number;
running: boolean;
inIntermission: boolean;
};
playerByGameStats: {
awayTeam: {
forwards: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
goals: number;
assists: number;
points: number;
plusMinus: number;
pim: number;
hits: number;
powerPlayGoals: number;
shots: number;
faceoffWinningPctg: number;
toi: string;
}[];
defense: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
goals: number;
assists: number;
points: number;
plusMinus: number;
pim: number;
hits: number;
powerPlayGoals: number;
shots: number;
faceoffWinningPctg: number;
toi: string;
}[];
goalies: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
evenStrengthShotsAgainst: string;
powerPlayShotsAgainst: string;
shorthandedShotsAgainst: string;
saveShotsAgainst: string;
evenStrengthGoalsAgainst: number;
powerPlayGoalsAgainst: number;
shorthandedGoalsAgainst: number;
pim: number;
goalsAgainst: number;
toi: string;
starter: boolean;
decision?: string;
savePctg?: string;
}[];
};
homeTeam: {
forwards: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
goals: number;
assists: number;
points: number;
plusMinus: number;
pim: number;
hits: number;
powerPlayGoals: number;
shots: number;
faceoffWinningPctg: number;
toi: string;
}[];
defense: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
goals: number;
assists: number;
points: number;
plusMinus: number;
pim: number;
hits: number;
powerPlayGoals: number;
shots: number;
faceoffWinningPctg: number;
toi: string;
}[];
goalies: {
playerId: number;
sweaterNumber: number;
name: DisplayValue;
position: string;
evenStrengthShotsAgainst: string;
powerPlayShotsAgainst: string;
shorthandedShotsAgainst: string;
saveShotsAgainst: string;
evenStrengthGoalsAgainst: number;
powerPlayGoalsAgainst: number;
shorthandedGoalsAgainst: number;
pim: number;
goalsAgainst: number;
toi: string;
starter: boolean;
decision?: string;
savePctg?: string;
}[];
};
};
summary: {
linescore: {
byPeriod: {
periodDescriptor: {
number: number;
periodType: string;
};
away: number;
home: number;
}[];
totals: {
away: number;
home: number;
};
};
shotsByPeriod: {
periodDescriptor: {
number: number;
periodType: string;
};
away: number;
home: number;
}[];
teamGameStats: {
category: string;
awayValue: number | string;
homeValue: number | string;
}[];
seasonSeries: {
id: number;
season: number;
gameType: number;
gameDate: string;
startTimeUTC: string;
easternUTCOffset: string;
venueUTCOffset: string;
gameState: string;
gameScheduleState: string;
awayTeam: {
id: number;
abbrev: string;
logo: string;
score: number;
};
homeTeam: {
id: number;
abbrev: string;
logo: string;
score: number;
};
summary: {
linescore: {
byPeriod: {
periodDescriptor: {
number: number;
periodType: string;
};
away: number;
home: number;
}[];
totals: {
away: number;
home: number;
};
};
};
}[];
};
};
type Schedule = {
nextStartDate: string;
previousStartDate: string;
gameWeek: {
date: string;
dayAbbrev: string;
numberOfGames: number;
games: {
id: number;
season: number;
gameType: number;
venue: string;
neutralSite: boolean;
startTimeUTC: string;
easternUTCOffset: string;
venueUTCOffset: string;
venueTimezone: string;
gameState: string;
gameScheduleState: string;
tvBroadcasts: {
id: number;
market: string;
countryCode: string;
network: string;
}[];
awayTeam: {
id: number;
city: string;
abbrev: string;
logo: string;
awaySplitSquad: boolean;
score: number;
};
homeTeam: {
id: number;
city: string;
abbrev: string;
logo: string;
homeSplitSquad: boolean;
score: number;
};
gameOutcome: {
lastPeriodType: string;
};
winningGoalie: {
playerId: number;
firstInitial: string;
lastName: string;
};
winningGoalScorer: {
playerId: number;
firstInitial: string;
lastName: string;
};
specialEvent: string;
gameCenterLink: string;
}[];
}[];
oddsPartners: {
partnerId: number;
country: string;
name: string;
imageUrl: string;
siteUrl?: string;
bgColor: string;
textColor: string;
accentColor: string;
}[];
preSeasonStartDate: string;
regularSeasonStartDate: string;
regularSeasonEndDate: string;
playoffEndDate: string;
numberOfGames: number;
};
/**
* Retrieve the Boxscore details, including the game metadata, venue & broadcast info, and player statistics.
* @param gameId the game ID in the format '2023020001'
* @returns the Boxscore with statistics and game metadata
*/
declare const getBoxscore: (gameId: number | string) => Promise<Boxscore>;
type TeamAbbr = 'ANA' | 'BOS' | 'BUF' | 'CAR' | 'CBJ' | 'CGY' | 'CHI' | 'COL' | 'DAL' | 'DET' | 'EDM' | 'FLA' | 'LAK' | 'MIN' | 'MTL' | 'NJD' | 'NYI' | 'NYR' | 'OTT' | 'PHI' | 'PIT' | 'SEA' | 'SJS' | 'STL' | 'TBL' | 'TOR' | 'VAN' | 'VGK' | 'WSH';
export { type Boxscore, type DisplayValue, type Schedule, type TeamAbbr, getBoxscore };