nhl-api-ts 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +72 -5
  2. package/dist/api/draft.d.mts +61 -0
  3. package/dist/api/draft.mjs +68 -0
  4. package/dist/api/edge.d.mts +198 -1
  5. package/dist/api/edge.mjs +207 -4
  6. package/dist/api/game-center.d.mts +49 -1
  7. package/dist/api/game-center.mjs +47 -0
  8. package/dist/api/misc.d.mts +115 -1
  9. package/dist/api/misc.mjs +147 -2
  10. package/dist/api/players.d.mts +55 -3
  11. package/dist/api/players.mjs +80 -3
  12. package/dist/api/query/cayenne.d.mts +4 -0
  13. package/dist/api/query/cayenne.mjs +13 -0
  14. package/dist/api/query/sorting/sorting-options.d.mts +8 -0
  15. package/dist/api/query/sorting/sorting-options.mjs +30 -0
  16. package/dist/api/schedule.d.mts +19 -6
  17. package/dist/api/schedule.mjs +17 -5
  18. package/dist/api/stats.d.mts +95 -6
  19. package/dist/api/stats.mjs +130 -30
  20. package/dist/api/teams.d.mts +43 -3
  21. package/dist/api/teams.mjs +51 -3
  22. package/dist/cli/commands.mjs +487 -22
  23. package/dist/http-client.d.mts +2 -1
  24. package/dist/http-client.mjs +8 -1
  25. package/dist/index.d.mts +8 -2
  26. package/dist/index.mjs +3 -0
  27. package/dist/nhl-client.d.mts +69 -14
  28. package/dist/nhl-client.mjs +33 -12
  29. package/dist/types/draft.d.mts +97 -0
  30. package/dist/types/draft.mjs +1 -0
  31. package/dist/types/edge.d.mts +299 -3
  32. package/dist/types/game-center.d.mts +223 -8
  33. package/dist/types/index.d.mts +1 -0
  34. package/dist/types/misc.d.mts +101 -0
  35. package/dist/types/misc.mjs +0 -1
  36. package/dist/types/players.d.mts +22 -0
  37. package/dist/types/schedule.d.mts +16 -0
  38. package/dist/types/stats.d.mts +207 -1
  39. package/dist/types/teams.d.mts +29 -1
  40. package/package.json +1 -1
@@ -108,6 +108,8 @@ export interface BoxscoreTeam {
108
108
  placeNameWithPreposition: LocalizedString;
109
109
  score?: number;
110
110
  sog?: number;
111
+ /** Only present while the game is live */
112
+ radioLink?: string;
111
113
  }
112
114
  export interface DailyScores {
113
115
  prevDate: string;
@@ -325,6 +327,8 @@ export interface GameLandingAwayTeam {
325
327
  record?: string;
326
328
  score?: number;
327
329
  sog?: number;
330
+ /** Only present while the game is live */
331
+ radioLink?: string;
328
332
  }
329
333
  export interface GameLandingMatchup {
330
334
  season: number;
@@ -370,6 +374,8 @@ export interface GameLandingSummary {
370
374
  scoring: GameLandingSummaryScoring[];
371
375
  threeStars: GameLandingSummaryThreeStar[];
372
376
  penalties: SummaryPenalty[];
377
+ /** Only present while the game is live */
378
+ iceSurface?: SummaryIceSurface;
373
379
  /** Only for games decided by a shootout */
374
380
  shootout?: SummaryShootout;
375
381
  }
@@ -432,6 +438,8 @@ export interface GameStoryAwayTeam {
432
438
  record?: string;
433
439
  score?: number;
434
440
  sog?: number;
441
+ /** Only present while the game is live */
442
+ radioLink?: string;
435
443
  }
436
444
  export interface PreGameMatchup {
437
445
  skatingLeaders: PreGameMatchupSkatingLeaders;
@@ -680,10 +688,13 @@ export interface PenaltyPlayer {
680
688
  }
681
689
  export interface PenaltyDetails {
682
690
  typeCode: string;
683
- descKey: OpenUnion<'elbowing' | 'holding-obstruction' | 'high-sticking' | 'interference' | 'holding-the-stick' | 'slashing' | 'cross-checking' | 'roughing' | 'holding' | 'hooking' | 'fighting' | 'tripping'>;
691
+ descKey: OpenUnion<'elbowing' | 'holding-obstruction' | 'high-sticking' | 'interference' | 'holding-the-stick' | 'slashing' | 'cross-checking' | 'roughing' | 'holding' | 'hooking' | 'fighting' | 'tripping' | 'instigator' | 'instigator-misconduct'>;
684
692
  duration: number;
685
693
  committedByPlayerId: number;
686
- drawnByPlayerId: number;
694
+ /** Absent for penalties nobody drew, e.g. misconducts */
695
+ drawnByPlayerId?: number;
696
+ /** Only when someone other than the committing player serves the penalty */
697
+ servedByPlayerId?: number;
687
698
  eventOwnerTeamId: number;
688
699
  xCoord?: number;
689
700
  yCoord?: number;
@@ -695,8 +706,11 @@ export interface PenaltyEntry {
695
706
  duration: number;
696
707
  committedByPlayer: PenaltyPlayer;
697
708
  teamAbbrev: LocalizedString;
698
- drawnBy: PenaltyPlayer;
699
- descKey: OpenUnion<'elbowing' | 'holding-obstruction' | 'high-sticking' | 'interference' | 'holding-the-stick' | 'slashing' | 'cross-checking' | 'roughing' | 'holding' | 'hooking' | 'fighting' | 'tripping'>;
709
+ /** Absent for penalties nobody drew, e.g. misconducts */
710
+ drawnBy?: PenaltyPlayer;
711
+ /** Name of the player serving the penalty, when not the one who committed it */
712
+ servedBy?: LocalizedString;
713
+ descKey: OpenUnion<'elbowing' | 'holding-obstruction' | 'high-sticking' | 'interference' | 'holding-the-stick' | 'slashing' | 'cross-checking' | 'roughing' | 'holding' | 'hooking' | 'fighting' | 'tripping' | 'instigator' | 'instigator-misconduct'>;
700
714
  }
701
715
  export interface PenaltyPlay {
702
716
  eventId: number;
@@ -781,8 +795,11 @@ export interface PlayByPlay {
781
795
  regPeriods: number;
782
796
  periodDescriptor?: PeriodDescriptor;
783
797
  gameOutcome?: GameOutcome;
784
- /** Empty object in every sample seen. */
785
- summary?: Record<string, never>;
798
+ summary?: PlayByPlaySummary;
799
+ }
800
+ export interface PlayByPlaySummary {
801
+ /** Only present while the game is live */
802
+ iceSurface?: SummaryIceSurface;
786
803
  }
787
804
  export interface PlayByPlayTeam {
788
805
  id: number;
@@ -794,6 +811,8 @@ export interface PlayByPlayTeam {
794
811
  placeName: LocalizedString;
795
812
  placeNameWithPreposition: LocalizedString;
796
813
  sog?: number;
814
+ /** Only present while the game is live */
815
+ radioLink?: string;
797
816
  }
798
817
  export interface PlayByPlayRosterSpot {
799
818
  teamId: number;
@@ -893,6 +912,8 @@ export interface RightRailSeasonSeries {
893
912
  periodDescriptor?: PeriodDescriptor;
894
913
  gameCenterLink: string;
895
914
  gameOutcome: GameOutcome;
915
+ /** Only present while the game is live */
916
+ clock?: GameClock;
896
917
  }
897
918
  export interface GameFullCoverageUrls {
898
919
  cs: string;
@@ -962,7 +983,7 @@ export interface ShiftEntry {
962
983
  duration: string | null;
963
984
  endTime: string;
964
985
  eventDescription: string | null;
965
- eventNumber: number;
986
+ eventNumber: number | null;
966
987
  firstName: string;
967
988
  gameId: number;
968
989
  hexValue: string;
@@ -1031,7 +1052,7 @@ export interface ShotOnGoalPlay {
1031
1052
  export interface SeasonStatsSkater {
1032
1053
  playerId: number;
1033
1054
  teamId: number;
1034
- sweaterNumber: number;
1055
+ sweaterNumber?: number;
1035
1056
  name: LocalizedString;
1036
1057
  position: string;
1037
1058
  gamesPlayed?: number;
@@ -1071,6 +1092,26 @@ export interface StoppagePlay {
1071
1092
  sortOrder: number;
1072
1093
  details: StoppageDetails;
1073
1094
  }
1095
+ /** The players on the ice right now, with their shift time on ice (`totalSOI`, seconds). */
1096
+ export interface SummaryIceSurface {
1097
+ awayTeam: IceSurfaceTeam;
1098
+ homeTeam: IceSurfaceTeam;
1099
+ }
1100
+ export interface IceSurfaceTeam {
1101
+ forwards: IceSurfacePlayer[];
1102
+ defensemen: IceSurfacePlayer[];
1103
+ goalies: IceSurfacePlayer[];
1104
+ /** Empty in every sample seen. */
1105
+ penaltyBox: unknown[];
1106
+ }
1107
+ export interface IceSurfacePlayer {
1108
+ playerId: number;
1109
+ name: LocalizedString;
1110
+ sweaterNumber: number;
1111
+ positionCode: PositionCode;
1112
+ headshot: string;
1113
+ totalSOI: number;
1114
+ }
1074
1115
  export interface SummaryPenalty {
1075
1116
  periodDescriptor: PeriodDescriptor;
1076
1117
  penalties: PenaltyEntry[];
@@ -1135,3 +1176,177 @@ export interface TeamSeasonStats {
1135
1176
  goalsForPerGamePlayedRank: number;
1136
1177
  goalsAgainstPerGamePlayedRank: number;
1137
1178
  }
1179
+ export interface GameMeta {
1180
+ teams: MetaTeam[];
1181
+ seasonStates: GameMetaSeasonState;
1182
+ gameState: GameState;
1183
+ }
1184
+ export interface GameMetaSeasonState {
1185
+ date: string;
1186
+ gameType: GameType;
1187
+ season: number;
1188
+ }
1189
+ /** A team as `meta` endpoints describe it. */
1190
+ export interface MetaTeam {
1191
+ name: LocalizedString;
1192
+ tricode: string;
1193
+ teamId: number;
1194
+ teamSlug: string;
1195
+ }
1196
+ export interface PlayReplay {
1197
+ id: number;
1198
+ gameDate: string;
1199
+ awayTeam: PlayReplayTeam;
1200
+ homeTeam: PlayReplayTeam;
1201
+ gameState: GameState;
1202
+ gameType: GameType;
1203
+ /** Only present when the event is a goal */
1204
+ goal?: PlayReplayGoal;
1205
+ }
1206
+ export interface PlayReplayGoal {
1207
+ periodDescriptor: PeriodDescriptor;
1208
+ situationCode: string;
1209
+ strength: string;
1210
+ playerId: number;
1211
+ firstName: LocalizedString;
1212
+ lastName: LocalizedString;
1213
+ name: LocalizedString;
1214
+ teamAbbrev: LocalizedString;
1215
+ headshot: string;
1216
+ highlightClip: number;
1217
+ logoUrl: string;
1218
+ highlightClipSharingUrl: string;
1219
+ goalsToDate: number;
1220
+ sweaterNumber: number;
1221
+ awayScore: number;
1222
+ homeScore: number;
1223
+ leadingTeamAbbrev: LocalizedString;
1224
+ timeInPeriod: string;
1225
+ shotType: ShotType;
1226
+ goalModifier: string;
1227
+ assists: GoalAssist[];
1228
+ pptReplayUrl: string;
1229
+ homeTeamDefendingSide: OpenUnion<'left' | 'right'>;
1230
+ isHome: boolean;
1231
+ eventId: number;
1232
+ }
1233
+ export interface PlayReplayTeam {
1234
+ id: number;
1235
+ name: LocalizedString;
1236
+ abbrev: string;
1237
+ placeName: LocalizedString;
1238
+ placeNameWithPreposition: LocalizedString;
1239
+ logo: string;
1240
+ darkLogo: string;
1241
+ }
1242
+ export interface Scoreboard {
1243
+ focusedDate: string;
1244
+ focusedDateCount: number;
1245
+ gamesByDate: ScoreboardDate[];
1246
+ }
1247
+ export interface ScoreboardDate {
1248
+ date: string;
1249
+ games: ScoreboardGame[];
1250
+ }
1251
+ export interface ScoreboardGame {
1252
+ id: number;
1253
+ season: number;
1254
+ gameType: GameType;
1255
+ gameDate: string;
1256
+ gameCenterLink: string;
1257
+ venue: LocalizedString;
1258
+ startTimeUTC: string;
1259
+ easternUTCOffset: string;
1260
+ venueUTCOffset: string;
1261
+ tvBroadcasts: DailyScoresTvBroadcast[];
1262
+ gameState: GameState;
1263
+ gameScheduleState: GameScheduleState;
1264
+ awayTeam: ScoreboardTeam;
1265
+ homeTeam: ScoreboardTeam;
1266
+ /** Absent before the game starts */
1267
+ period?: number;
1268
+ /** Absent before the game starts */
1269
+ periodDescriptor?: PeriodDescriptor;
1270
+ /** Only present while the game is live */
1271
+ clock?: GameClock;
1272
+ /** Absent before the game is played */
1273
+ threeMinRecap?: string;
1274
+ /** Absent before the game is played */
1275
+ threeMinRecapFr?: string;
1276
+ /** Only present before the game starts */
1277
+ ticketsLink?: string;
1278
+ /** Only present before the game starts */
1279
+ ticketsLinkFr?: string;
1280
+ /** Playoff games only */
1281
+ seriesStatus?: ScoreboardSeriesStatus;
1282
+ }
1283
+ export interface ScoreboardSeriesStatus {
1284
+ round: number;
1285
+ seriesAbbrev: string;
1286
+ game: number;
1287
+ topSeedTeamAbbrev: string;
1288
+ topSeedWins: number;
1289
+ bottomSeedTeamAbbrev: string;
1290
+ bottomSeedWins: number;
1291
+ }
1292
+ export interface ScoreboardTeam {
1293
+ id: number;
1294
+ name: LocalizedString;
1295
+ commonName: LocalizedString;
1296
+ placeNameWithPreposition: LocalizedString;
1297
+ abbrev: string;
1298
+ /** Absent before the game starts */
1299
+ score?: number;
1300
+ /** Only present while the game is live */
1301
+ sog?: number;
1302
+ logo: string;
1303
+ /** Only present before the game starts */
1304
+ record?: string;
1305
+ }
1306
+ /** A play from `wsc/play-by-play`. Flat, unlike {@link Play}: event details sit on the play itself. */
1307
+ export interface WscPlay {
1308
+ id: number;
1309
+ eventId: number;
1310
+ period: number;
1311
+ timeInPeriod: string;
1312
+ secondsRemaining: number;
1313
+ typeCode: number;
1314
+ typeDescKey: OpenUnion<'shot-on-goal' | 'penalty' | 'goal' | 'period-start' | 'faceoff' | 'giveaway' | 'missed-shot' | 'takeaway' | 'blocked-shot' | 'hit' | 'delayed-penalty' | 'period-end' | 'game-end'>;
1315
+ sortOrder: number;
1316
+ shotType?: ShotType;
1317
+ shootingPlayerId?: number;
1318
+ goalieInNetId?: number;
1319
+ eventOwnerTeamId?: number;
1320
+ awaySOG?: number;
1321
+ homeSOG?: number;
1322
+ penaltyTypeCode?: string;
1323
+ descKey?: OpenUnion<'elbowing' | 'holding-obstruction' | 'high-sticking' | 'interference' | 'holding-the-stick' | 'slashing' | 'cross-checking' | 'roughing' | 'holding' | 'hooking' | 'fighting' | 'tripping'>;
1324
+ duration?: number;
1325
+ committedByPlayerId?: number;
1326
+ drawnByPlayerId?: number;
1327
+ goalModifier?: string;
1328
+ strength?: string;
1329
+ scoringPlayerId?: number;
1330
+ assist1PlayerId?: number;
1331
+ assist2PlayerId?: number;
1332
+ awayScore?: number;
1333
+ homeScore?: number;
1334
+ strengthCode?: number;
1335
+ goalCode?: number;
1336
+ scoringPlayerTotal?: number;
1337
+ assist1PlayerTotal?: number;
1338
+ assist2PlayerTotal?: number;
1339
+ situationCode?: string;
1340
+ homeTeamDefendingSide?: OpenUnion<'left' | 'right'>;
1341
+ utc?: string;
1342
+ losingPlayerId?: number;
1343
+ winningPlayerId?: number;
1344
+ xCoord?: number;
1345
+ yCoord?: number;
1346
+ zoneCode?: ZoneCode;
1347
+ playerId?: number;
1348
+ reason?: OpenUnion<'hit-right-post' | 'wide-right' | 'blocked' | 'high-and-wide-right' | 'wide-left' | 'above-crossbar' | 'short' | 'high-and-wide-left' | 'teammate-blocked' | 'hit-crossbar' | 'hit-left-post'>;
1349
+ blockingPlayerId?: number;
1350
+ hittingPlayerId?: number;
1351
+ hitteePlayerId?: number;
1352
+ }
@@ -1,4 +1,5 @@
1
1
  export type * from '#src/types/common.mjs';
2
+ export type * from '#src/types/draft.mjs';
2
3
  export type * from '#src/types/edge.mjs';
3
4
  export type * from '#src/types/game-center.mjs';
4
5
  export type * from '#src/types/helpers.mjs';
@@ -1,3 +1,11 @@
1
+ import type { GameType, LocalizedString, OddsPartner, OpenUnion } from '#src/types/common.mjs';
2
+ import type { MetaTeam } from '#src/types/game-center.mjs';
3
+ export interface ComponentSeason {
4
+ id: string;
5
+ component: string;
6
+ gameTypeId: GameType;
7
+ seasonId: number;
8
+ }
1
9
  export interface Country {
2
10
  id: string;
3
11
  country3Code: string;
@@ -16,6 +24,9 @@ export interface DraftYear {
16
24
  draftYear: number;
17
25
  rounds: number;
18
26
  }
27
+ export interface GeoLocation {
28
+ country: string;
29
+ }
19
30
  export interface GlossaryEntry {
20
31
  id: number;
21
32
  abbreviation: string;
@@ -25,6 +36,62 @@ export interface GlossaryEntry {
25
36
  languageCode: string;
26
37
  lastUpdated: string;
27
38
  }
39
+ export interface Meta {
40
+ players: MetaPlayer[];
41
+ teams: MetaTeam[];
42
+ /** Empty in every observed response */
43
+ seasonStates: unknown[];
44
+ }
45
+ export interface MetaPlayer {
46
+ playerId: number;
47
+ playerSlug: string;
48
+ actionShot: string;
49
+ name: LocalizedString;
50
+ currentTeams: MetaPlayerTeam[];
51
+ isGoalie: boolean;
52
+ }
53
+ export interface MetaPlayerTeam {
54
+ teamId: number;
55
+ abbrev: string;
56
+ force: boolean;
57
+ }
58
+ export interface PartnerGameOdd {
59
+ description: OpenUnion<'MONEY_LINE_2_WAY' | 'MONEY_LINE_3_WAY' | 'OVER_UNDER' | 'PUCK_LINE'>;
60
+ value: number;
61
+ /** The line, e.g. "-1.5" or "O5.5"; "Draw" for the 3-way draw price; "" otherwise */
62
+ qualifier: string;
63
+ }
64
+ export interface PartnerGameOdds {
65
+ currentOddsDate: string;
66
+ lastUpdatedUTC: string;
67
+ bettingPartner: OddsPartner;
68
+ games: PartnerGameOddsGame[];
69
+ }
70
+ export interface PartnerGameOddsGame {
71
+ gameId: number;
72
+ gameType: GameType;
73
+ startTimeUTC: string;
74
+ homeTeam: PartnerGameOddsTeam;
75
+ awayTeam: PartnerGameOddsTeam;
76
+ }
77
+ export interface PartnerGameOddsTeam {
78
+ id: number;
79
+ name: LocalizedString;
80
+ abbrev: string;
81
+ logo: string;
82
+ odds: PartnerGameOdd[];
83
+ }
84
+ export interface PostalLookupTeam {
85
+ stateProvince: string;
86
+ teamName: LocalizedString;
87
+ postalCode: string;
88
+ country: string;
89
+ city: string;
90
+ /** Absent for Canadian postal codes */
91
+ networkType?: string;
92
+ /** Absent for Canadian postal codes */
93
+ county?: string;
94
+ }
28
95
  export interface ReportColumns {
29
96
  displayItems: string[];
30
97
  resultFilters: string[];
@@ -66,3 +133,37 @@ export interface StatsConfig {
66
133
  aggregatedColumns: string[];
67
134
  individualColumns: string[];
68
135
  }
136
+ /** One game of the stats API (`en/game`). */
137
+ export interface StatsGame {
138
+ id: number;
139
+ easternStartTime: string;
140
+ gameDate: string;
141
+ gameNumber: number;
142
+ gameScheduleStateId: number;
143
+ gameStateId: number;
144
+ gameType: GameType;
145
+ homeScore: number;
146
+ homeTeamId: number;
147
+ period: number;
148
+ season: number;
149
+ visitingScore: number;
150
+ visitingTeamId: number;
151
+ }
152
+ export interface TvSchedule {
153
+ date: string;
154
+ startDate: string;
155
+ endDate: string;
156
+ broadcasts: TvScheduleBroadcast[];
157
+ }
158
+ export interface TvScheduleBroadcast {
159
+ startTime: string;
160
+ endTime: string;
161
+ durationSeconds: number;
162
+ title: string;
163
+ description: string;
164
+ houseNumber: string;
165
+ broadcastType: OpenUnion<'HD'>;
166
+ /** "LIVE" for live games, "" otherwise */
167
+ broadcastStatus: OpenUnion<'LIVE' | ''>;
168
+ broadcastImageUrl: string;
169
+ }
@@ -1,2 +1 @@
1
- // Response types derived from live NHL API probing. See CONTRIBUTING.md.
2
1
  export {};
@@ -1,5 +1,17 @@
1
1
  import type { LocalizedString, PositionCode, ShootsCatches } from '#src/types/common.mjs';
2
2
  import type { RosterPlayer } from '#src/types/teams.mjs';
3
+ export interface PlayerSpotlight {
4
+ playerId: number;
5
+ name: LocalizedString;
6
+ playerSlug: string;
7
+ position: PositionCode;
8
+ sweaterNumber: number;
9
+ teamId: number;
10
+ headshot: string;
11
+ teamTriCode: string;
12
+ teamLogo: string;
13
+ sortId: number;
14
+ }
3
15
  export interface Prospects {
4
16
  forwards: ProspectsForward[];
5
17
  defensemen: RosterPlayer[];
@@ -39,3 +51,13 @@ export interface ProspectsGoalie {
39
51
  birthCity: LocalizedString;
40
52
  birthCountry: string;
41
53
  }
54
+ /** One row of the stats API player search (`en/players`). */
55
+ export interface StatsPlayer {
56
+ id: number;
57
+ currentTeamId: number | null;
58
+ firstName: string;
59
+ fullName: string;
60
+ lastName: string;
61
+ positionCode: PositionCode;
62
+ sweaterNumber: number | null;
63
+ }
@@ -225,6 +225,20 @@ export interface PlayoffSeriesGameTeam {
225
225
  abbrev: string;
226
226
  score: number;
227
227
  }
228
+ export interface PlayoffSeriesMeta {
229
+ seriesTitle: string;
230
+ teams: PlayoffSeriesMetaTeams;
231
+ }
232
+ export interface PlayoffSeriesMetaTeam {
233
+ name: LocalizedString;
234
+ commonName: LocalizedString;
235
+ tricode: string;
236
+ teamSlug: string;
237
+ }
238
+ export interface PlayoffSeriesMetaTeams {
239
+ topSeed: PlayoffSeriesMetaTeam;
240
+ bottomSeed: PlayoffSeriesMetaTeam;
241
+ }
228
242
  export interface PlayoffSeriesStatus {
229
243
  topSeedWins: number;
230
244
  bottomSeedWins: number;
@@ -367,7 +381,9 @@ export interface SeasonScheduleSeriesStatus {
367
381
  seriesTitle: string;
368
382
  seriesLetter: string;
369
383
  neededToWin: number;
384
+ topSeedTeamAbbrev: string;
370
385
  topSeedWins: number;
386
+ bottomSeedTeamAbbrev: string;
371
387
  bottomSeedWins: number;
372
388
  gameNumberOfSeries: number;
373
389
  }