nhl-api-ts 0.2.0 → 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.
- package/README.md +81 -9
- package/dist/api/draft.d.mts +61 -0
- package/dist/api/draft.mjs +68 -0
- package/dist/api/edge.d.mts +221 -24
- package/dist/api/edge.mjs +276 -27
- package/dist/api/game-center.d.mts +63 -15
- package/dist/api/game-center.mjs +67 -8
- package/dist/api/helpers.d.mts +6 -6
- package/dist/api/helpers.mjs +6 -6
- package/dist/api/misc.d.mts +120 -6
- package/dist/api/misc.mjs +162 -7
- package/dist/api/players.d.mts +59 -7
- package/dist/api/players.mjs +85 -4
- package/dist/api/query/cayenne.d.mts +4 -0
- package/dist/api/query/cayenne.mjs +13 -0
- package/dist/api/query/sorting/sorting-options.d.mts +8 -0
- package/dist/api/query/sorting/sorting-options.mjs +30 -0
- package/dist/api/schedule.d.mts +36 -23
- package/dist/api/schedule.mjs +40 -16
- package/dist/api/standings.d.mts +3 -3
- package/dist/api/standings.mjs +4 -4
- package/dist/api/stats.d.mts +105 -16
- package/dist/api/stats.mjs +145 -41
- package/dist/api/teams.d.mts +48 -8
- package/dist/api/teams.mjs +59 -7
- package/dist/cli/colors.d.mts +2 -2
- package/dist/cli/colors.mjs +6 -2
- package/dist/cli/commands.mjs +521 -46
- package/dist/cli/run.mjs +7 -5
- package/dist/http-client.d.mts +2 -1
- package/dist/http-client.mjs +10 -3
- package/dist/index.d.mts +8 -2
- package/dist/index.mjs +3 -0
- package/dist/nhl-client.d.mts +70 -15
- package/dist/nhl-client.mjs +40 -17
- package/dist/types/common.d.mts +0 -1
- package/dist/types/draft.d.mts +97 -0
- package/dist/types/draft.mjs +1 -0
- package/dist/types/edge.d.mts +301 -5
- package/dist/types/game-center.d.mts +277 -119
- package/dist/types/index.d.mts +1 -0
- package/dist/types/misc.d.mts +101 -0
- package/dist/types/misc.mjs +0 -1
- package/dist/types/players.d.mts +23 -2
- package/dist/types/schedule.d.mts +50 -62
- package/dist/types/standings.d.mts +1 -2
- package/dist/types/stats.d.mts +313 -111
- package/dist/types/teams.d.mts +29 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.mjs +3 -1
- package/package.json +7 -28
package/dist/api/edge.mjs
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
import { Endpoint } from '#src/http-client.mjs';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/** Player positions of an EDGE top-10 leaderboard. */
|
|
3
|
+
export const EdgePositions = {
|
|
4
|
+
ALL: 'all',
|
|
5
|
+
FORWARDS: 'forwards',
|
|
6
|
+
DEFENSE: 'defense',
|
|
7
|
+
};
|
|
8
|
+
/** Game strengths of an EDGE top-10 leaderboard. */
|
|
9
|
+
export const EdgeStrengths = {
|
|
10
|
+
ALL: 'all',
|
|
11
|
+
EVEN: 'es',
|
|
12
|
+
POWER_PLAY: 'pp',
|
|
13
|
+
PENALTY_KILL: 'pk',
|
|
14
|
+
};
|
|
15
|
+
/** Rink zones; the `sortBy` of the zone time top-10s. */
|
|
16
|
+
export const EdgeZones = {
|
|
17
|
+
OFFENSIVE: 'offensive',
|
|
18
|
+
NEUTRAL: 'neutral',
|
|
19
|
+
DEFENSIVE: 'defensive',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* "<path>/<segments...>/now" when no season is given, else
|
|
23
|
+
* "<path>/<segments...>/<season>/<gameType>".
|
|
24
|
+
*/
|
|
25
|
+
function edgeResource(path, segments, { season, gameType = 2 }) {
|
|
26
|
+
const base = [path, ...segments].join('/');
|
|
5
27
|
if (season === undefined || season === null) {
|
|
6
28
|
return `${base}/now`;
|
|
7
29
|
}
|
|
8
30
|
return `${base}/${season}/${gameType}`;
|
|
9
31
|
}
|
|
32
|
+
async function getEdgeSegments(ctx, path, segments, params) {
|
|
33
|
+
return (await ctx.get(Endpoint.API_WEB_V1, edgeResource(path, segments, params))).json();
|
|
34
|
+
}
|
|
10
35
|
async function getEdge(ctx, path, id, params) {
|
|
11
|
-
return (
|
|
36
|
+
return getEdgeSegments(ctx, path, id === undefined ? [] : [id], params);
|
|
12
37
|
}
|
|
13
38
|
// ========================
|
|
14
39
|
// SKATER ENDPOINTS
|
|
@@ -18,55 +43,73 @@ async function getEdge(ctx, path, id, params) {
|
|
|
18
43
|
*
|
|
19
44
|
* @example await client.edge.skaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
20
45
|
*/
|
|
21
|
-
export
|
|
46
|
+
export async function skaterDetail(ctx, params) {
|
|
47
|
+
return getEdge(ctx, 'edge/skater-detail', params.playerId, params);
|
|
48
|
+
}
|
|
22
49
|
/**
|
|
23
50
|
* Get NHL EDGE shot speed details for a specific skater.
|
|
24
51
|
*
|
|
25
52
|
* @example await client.edge.skaterShotSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
26
53
|
*/
|
|
27
|
-
export
|
|
54
|
+
export async function skaterShotSpeedDetail(ctx, params) {
|
|
55
|
+
return getEdge(ctx, 'edge/skater-shot-speed-detail', params.playerId, params);
|
|
56
|
+
}
|
|
28
57
|
/**
|
|
29
58
|
* Get NHL EDGE skating speed details for a specific skater.
|
|
30
59
|
*
|
|
31
60
|
* @example await client.edge.skaterSkatingSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
32
61
|
*/
|
|
33
|
-
export
|
|
62
|
+
export async function skaterSkatingSpeedDetail(ctx, params) {
|
|
63
|
+
return getEdge(ctx, 'edge/skater-skating-speed-detail', params.playerId, params);
|
|
64
|
+
}
|
|
34
65
|
/**
|
|
35
66
|
* Get NHL EDGE shot location details for a specific skater.
|
|
36
67
|
*
|
|
37
68
|
* @example await client.edge.skaterShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
38
69
|
*/
|
|
39
|
-
export
|
|
70
|
+
export async function skaterShotLocationDetail(ctx, params) {
|
|
71
|
+
return getEdge(ctx, 'edge/skater-shot-location-detail', params.playerId, params);
|
|
72
|
+
}
|
|
40
73
|
/**
|
|
41
74
|
* Get NHL EDGE skating distance details for a specific skater.
|
|
42
75
|
*
|
|
43
76
|
* @example await client.edge.skaterSkatingDistanceDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
44
77
|
*/
|
|
45
|
-
export
|
|
78
|
+
export async function skaterSkatingDistanceDetail(ctx, params) {
|
|
79
|
+
return getEdge(ctx, 'edge/skater-skating-distance-detail', params.playerId, params);
|
|
80
|
+
}
|
|
46
81
|
/**
|
|
47
82
|
* Get NHL EDGE comparison statistics for a specific skater.
|
|
48
83
|
*
|
|
49
84
|
* @example await client.edge.skaterComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
50
85
|
*/
|
|
51
|
-
export
|
|
86
|
+
export async function skaterComparison(ctx, params) {
|
|
87
|
+
return getEdge(ctx, 'edge/skater-comparison', params.playerId, params);
|
|
88
|
+
}
|
|
52
89
|
/**
|
|
53
90
|
* Get NHL EDGE zone time details for a specific skater.
|
|
54
91
|
*
|
|
55
92
|
* @example await client.edge.skaterZoneTime({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
56
93
|
*/
|
|
57
|
-
export
|
|
94
|
+
export async function skaterZoneTime(ctx, params) {
|
|
95
|
+
return getEdge(ctx, 'edge/skater-zone-time', params.playerId, params);
|
|
96
|
+
}
|
|
58
97
|
/**
|
|
59
98
|
* Get NHL EDGE skater landing page data.
|
|
60
99
|
*
|
|
61
100
|
* @example await client.edge.skaterLanding({ season: '20232024' })
|
|
62
101
|
*/
|
|
63
|
-
export
|
|
102
|
+
export async function skaterLanding(ctx, params = {}) {
|
|
103
|
+
return getEdge(ctx, 'edge/skater-landing', undefined, params);
|
|
104
|
+
}
|
|
64
105
|
/**
|
|
65
106
|
* Get NHL CAT (Catch All Tracking) EDGE skater details.
|
|
66
107
|
*
|
|
67
108
|
* @example await client.edge.catSkaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
68
109
|
*/
|
|
69
|
-
export
|
|
110
|
+
export async function catSkaterDetail(ctx, params) {
|
|
111
|
+
return getEdge(ctx, 'cat/edge/skater-detail', params.playerId, params);
|
|
112
|
+
}
|
|
70
113
|
// ========================
|
|
71
114
|
// GOALIE ENDPOINTS
|
|
72
115
|
// ========================
|
|
@@ -75,43 +118,57 @@ export const catSkaterDetail = async (ctx, params) => getEdge(ctx, 'cat/edge/ska
|
|
|
75
118
|
*
|
|
76
119
|
* @example await client.edge.goalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
77
120
|
*/
|
|
78
|
-
export
|
|
121
|
+
export async function goalieDetail(ctx, params) {
|
|
122
|
+
return getEdge(ctx, 'edge/goalie-detail', params.playerId, params);
|
|
123
|
+
}
|
|
79
124
|
/**
|
|
80
125
|
* Get NHL EDGE shot location details for a specific goalie.
|
|
81
126
|
*
|
|
82
127
|
* @example await client.edge.goalieShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
83
128
|
*/
|
|
84
|
-
export
|
|
129
|
+
export async function goalieShotLocationDetail(ctx, params) {
|
|
130
|
+
return getEdge(ctx, 'edge/goalie-shot-location-detail', params.playerId, params);
|
|
131
|
+
}
|
|
85
132
|
/**
|
|
86
133
|
* Get NHL EDGE 5v5 performance details for a specific goalie.
|
|
87
134
|
*
|
|
88
135
|
* @example await client.edge.goalie5v5Detail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
89
136
|
*/
|
|
90
|
-
export
|
|
137
|
+
export async function goalie5v5Detail(ctx, params) {
|
|
138
|
+
return getEdge(ctx, 'edge/goalie-5v5-detail', params.playerId, params);
|
|
139
|
+
}
|
|
91
140
|
/**
|
|
92
141
|
* Get NHL EDGE comparison statistics for a specific goalie.
|
|
93
142
|
*
|
|
94
143
|
* @example await client.edge.goalieComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
95
144
|
*/
|
|
96
|
-
export
|
|
145
|
+
export async function goalieComparison(ctx, params) {
|
|
146
|
+
return getEdge(ctx, 'edge/goalie-comparison', params.playerId, params);
|
|
147
|
+
}
|
|
97
148
|
/**
|
|
98
149
|
* Get NHL EDGE save percentage details for a specific goalie.
|
|
99
150
|
*
|
|
100
151
|
* @example await client.edge.goalieSavePercentageDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
101
152
|
*/
|
|
102
|
-
export
|
|
153
|
+
export async function goalieSavePercentageDetail(ctx, params) {
|
|
154
|
+
return getEdge(ctx, 'edge/goalie-save-percentage-detail', params.playerId, params);
|
|
155
|
+
}
|
|
103
156
|
/**
|
|
104
157
|
* Get NHL EDGE goalie landing page data.
|
|
105
158
|
*
|
|
106
159
|
* @example await client.edge.goalieLanding({ season: '20232024' })
|
|
107
160
|
*/
|
|
108
|
-
export
|
|
161
|
+
export async function goalieLanding(ctx, params = {}) {
|
|
162
|
+
return getEdge(ctx, 'edge/goalie-landing', undefined, params);
|
|
163
|
+
}
|
|
109
164
|
/**
|
|
110
165
|
* Get NHL CAT (Catch All Tracking) EDGE goalie details.
|
|
111
166
|
*
|
|
112
167
|
* @example await client.edge.catGoalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
113
168
|
*/
|
|
114
|
-
export
|
|
169
|
+
export async function catGoalieDetail(ctx, params) {
|
|
170
|
+
return getEdge(ctx, 'cat/edge/goalie-detail', params.playerId, params);
|
|
171
|
+
}
|
|
115
172
|
// ========================
|
|
116
173
|
// TEAM ENDPOINTS
|
|
117
174
|
// ========================
|
|
@@ -120,43 +177,220 @@ export const catGoalieDetail = async (ctx, params) => getEdge(ctx, 'cat/edge/goa
|
|
|
120
177
|
*
|
|
121
178
|
* @example await client.edge.teamDetail({ teamId: 10 })
|
|
122
179
|
*/
|
|
123
|
-
export
|
|
180
|
+
export async function teamDetail(ctx, params) {
|
|
181
|
+
return getEdge(ctx, 'edge/team-detail', params.teamId, params);
|
|
182
|
+
}
|
|
124
183
|
/**
|
|
125
184
|
* Get NHL EDGE skating distance details for a specific team.
|
|
126
185
|
*
|
|
127
186
|
* @example await client.edge.teamSkatingDistanceDetail({ teamId: 10 })
|
|
128
187
|
*/
|
|
129
|
-
export
|
|
188
|
+
export async function teamSkatingDistanceDetail(ctx, params) {
|
|
189
|
+
return getEdge(ctx, 'edge/team-skating-distance-detail', params.teamId, params);
|
|
190
|
+
}
|
|
130
191
|
/**
|
|
131
192
|
* Get NHL EDGE zone time details for a specific team.
|
|
132
193
|
*
|
|
133
194
|
* @example await client.edge.teamZoneTimeDetails({ teamId: 10 })
|
|
134
195
|
*/
|
|
135
|
-
export
|
|
196
|
+
export async function teamZoneTimeDetails(ctx, params) {
|
|
197
|
+
return getEdge(ctx, 'edge/team-zone-time-details', params.teamId, params);
|
|
198
|
+
}
|
|
136
199
|
/**
|
|
137
200
|
* Get NHL EDGE shot location details for a specific team.
|
|
138
201
|
*
|
|
139
202
|
* @example await client.edge.teamShotLocationDetail({ teamId: 10 })
|
|
140
203
|
*/
|
|
141
|
-
export
|
|
204
|
+
export async function teamShotLocationDetail(ctx, params) {
|
|
205
|
+
return getEdge(ctx, 'edge/team-shot-location-detail', params.teamId, params);
|
|
206
|
+
}
|
|
142
207
|
/**
|
|
143
208
|
* Get NHL EDGE team landing page data.
|
|
144
209
|
*
|
|
145
210
|
* @example await client.edge.teamLanding({ season: '20232024' })
|
|
146
211
|
*/
|
|
147
|
-
export
|
|
212
|
+
export async function teamLanding(ctx, params = {}) {
|
|
213
|
+
return getEdge(ctx, 'edge/team-landing', undefined, params);
|
|
214
|
+
}
|
|
148
215
|
/**
|
|
149
216
|
* Get NHL EDGE shot speed details for a specific team.
|
|
150
217
|
*
|
|
151
218
|
* @example await client.edge.teamShotSpeedDetail({ teamId: 10 })
|
|
152
219
|
*/
|
|
153
|
-
export
|
|
220
|
+
export async function teamShotSpeedDetail(ctx, params) {
|
|
221
|
+
return getEdge(ctx, 'edge/team-shot-speed-detail', params.teamId, params);
|
|
222
|
+
}
|
|
154
223
|
/**
|
|
155
224
|
* Get NHL EDGE skating speed details for a specific team.
|
|
156
225
|
*
|
|
157
226
|
* @example await client.edge.teamSkatingSpeedDetail({ teamId: 10 })
|
|
158
227
|
*/
|
|
159
|
-
export
|
|
228
|
+
export async function teamSkatingSpeedDetail(ctx, params) {
|
|
229
|
+
return getEdge(ctx, 'edge/team-skating-speed-detail', params.teamId, params);
|
|
230
|
+
}
|
|
231
|
+
// ========================
|
|
232
|
+
// LEADERBOARDS (TOP 10)
|
|
233
|
+
// ========================
|
|
234
|
+
/**
|
|
235
|
+
* Get the NHL EDGE top 10 skaters by skating distance.
|
|
236
|
+
*
|
|
237
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
238
|
+
* @param params.strength 'all' (default), 'es', 'pp' or 'pk'
|
|
239
|
+
* @param params.sortBy 'total', 'per-60', 'max-game' or 'max-period'
|
|
240
|
+
* @example https://api-web.nhle.com/v1/edge/skater-distance-top-10/all/all/total/20252026/2
|
|
241
|
+
*/
|
|
242
|
+
export async function skaterDistanceTop10(ctx, { positions = EdgePositions.ALL, strength = EdgeStrengths.ALL, sortBy, ...params }) {
|
|
243
|
+
return getEdgeSegments(ctx, 'edge/skater-distance-top-10', [positions, strength, sortBy], params);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the NHL EDGE top 10 skaters by skating speed.
|
|
247
|
+
*
|
|
248
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
249
|
+
* @param params.sortBy 'max', 'over-22', '20-22' or '18-20' (bursts in mph)
|
|
250
|
+
* @example https://api-web.nhle.com/v1/edge/skater-speed-top-10/all/max/20252026/2
|
|
251
|
+
*/
|
|
252
|
+
export async function skaterSpeedTop10(ctx, { positions = EdgePositions.ALL, sortBy, ...params }) {
|
|
253
|
+
return getEdgeSegments(ctx, 'edge/skater-speed-top-10', [positions, sortBy], params);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the NHL EDGE top 10 skaters by zone time.
|
|
257
|
+
*
|
|
258
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
259
|
+
* @param params.strength 'all' (default), 'es', 'pp' or 'pk'
|
|
260
|
+
* @param params.sortBy Zone: 'offensive', 'neutral' or 'defensive'. See `EdgeZones`.
|
|
261
|
+
* @example https://api-web.nhle.com/v1/edge/skater-zone-time-top-10/all/all/offensive/20252026/2
|
|
262
|
+
*/
|
|
263
|
+
export async function skaterZoneTimeTop10(ctx, { positions = EdgePositions.ALL, strength = EdgeStrengths.ALL, sortBy, ...params }) {
|
|
264
|
+
return getEdgeSegments(ctx, 'edge/skater-zone-time-top-10', [positions, strength, sortBy], params);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get the NHL EDGE top 10 skaters by shot speed.
|
|
268
|
+
*
|
|
269
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
270
|
+
* @param params.sortBy 'max', 'over-100', '90-99', '80-89' or '70-79' (attempts in mph)
|
|
271
|
+
* @example https://api-web.nhle.com/v1/edge/skater-shot-speed-top-10/all/max/20252026/2
|
|
272
|
+
*/
|
|
273
|
+
export async function skaterShotSpeedTop10(ctx, { positions = EdgePositions.ALL, sortBy, ...params }) {
|
|
274
|
+
return getEdgeSegments(ctx, 'edge/skater-shot-speed-top-10', [positions, sortBy], params);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get the NHL EDGE top 10 skaters by shot location. `sortBy` comes before
|
|
278
|
+
* `category` in the URL (the NHL-API-Reference has them the other way round,
|
|
279
|
+
* which 404s).
|
|
280
|
+
*
|
|
281
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'. 'F' / 'D' are a 404 here.
|
|
282
|
+
* @param params.sortBy 'sog', 'goals' or 'shooting-pctg'
|
|
283
|
+
* @param params.category 'all' (default), 'high', 'mid' or 'long'
|
|
284
|
+
* @example https://api-web.nhle.com/v1/edge/skater-shot-location-top-10/all/sog/all/20252026/2
|
|
285
|
+
*/
|
|
286
|
+
export async function skaterShotLocationTop10(ctx, { positions = EdgePositions.ALL, sortBy, category = 'all', ...params }) {
|
|
287
|
+
return getEdgeSegments(ctx, 'edge/skater-shot-location-top-10', [positions, sortBy, category], params);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Get the NHL EDGE top 10 goalies by 5v5 performance.
|
|
291
|
+
*
|
|
292
|
+
* @param params.sortBy 'save-pctg', 'save-pctg-close', 'shots' or 'shots-per-60'
|
|
293
|
+
* @example https://api-web.nhle.com/v1/edge/goalie-5v5-top-10/save-pctg/20252026/2
|
|
294
|
+
*/
|
|
295
|
+
export async function goalie5v5Top10(ctx, { sortBy, ...params }) {
|
|
296
|
+
return getEdgeSegments(ctx, 'edge/goalie-5v5-top-10', [sortBy], params);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get the NHL EDGE top 10 goalies by shot location.
|
|
300
|
+
*
|
|
301
|
+
* @param params.sortBy 'save-pctg', 'saves', 'goals-against' or 'shots-against'
|
|
302
|
+
* @param params.category 'all' (default), 'high', 'mid' or 'long'
|
|
303
|
+
* @example https://api-web.nhle.com/v1/edge/goalie-shot-location-top-10/save-pctg/all/20252026/2
|
|
304
|
+
*/
|
|
305
|
+
export async function goalieShotLocationTop10(ctx, { sortBy, category = 'all', ...params }) {
|
|
306
|
+
return getEdgeSegments(ctx, 'edge/goalie-shot-location-top-10', [sortBy, category], params);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get the NHL EDGE top 10 goalies by games above a .900 save percentage.
|
|
310
|
+
*
|
|
311
|
+
* @param params.sortBy 'games' (count) or 'pctg' (share of games played)
|
|
312
|
+
* @example https://api-web.nhle.com/v1/edge/goalie-edge-save-pctg-top-10/games/20252026/2
|
|
313
|
+
*/
|
|
314
|
+
export async function goalieSavePercentageTop10(ctx, { sortBy, ...params }) {
|
|
315
|
+
return getEdgeSegments(ctx, 'edge/goalie-edge-save-pctg-top-10', [sortBy], params);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get the NHL EDGE top 10 teams by skating distance.
|
|
319
|
+
*
|
|
320
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
321
|
+
* @param params.strength 'all' (default), 'es', 'pp' or 'pk'
|
|
322
|
+
* @param params.sortBy 'total', 'per-60', 'max-game' or 'max-period'
|
|
323
|
+
* @example https://api-web.nhle.com/v1/edge/team-skating-distance-top-10/all/all/total/20252026/2
|
|
324
|
+
*/
|
|
325
|
+
export async function teamSkatingDistanceTop10(ctx, { positions = EdgePositions.ALL, strength = EdgeStrengths.ALL, sortBy, ...params }) {
|
|
326
|
+
return getEdgeSegments(ctx, 'edge/team-skating-distance-top-10', [positions, strength, sortBy], params);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get the NHL EDGE top 10 teams by skating speed.
|
|
330
|
+
*
|
|
331
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
332
|
+
* @param params.sortBy 'max', 'over-22', '20-22' or '18-20' (bursts in mph)
|
|
333
|
+
* @example https://api-web.nhle.com/v1/edge/team-skating-speed-top-10/all/max/20252026/2
|
|
334
|
+
*/
|
|
335
|
+
export async function teamSkatingSpeedTop10(ctx, { positions = EdgePositions.ALL, sortBy, ...params }) {
|
|
336
|
+
return getEdgeSegments(ctx, 'edge/team-skating-speed-top-10', [positions, sortBy], params);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get the NHL EDGE top 10 teams by zone time. There is no `positions` slot.
|
|
340
|
+
*
|
|
341
|
+
* @param params.strength 'all' (default), 'es', 'pp' or 'pk'
|
|
342
|
+
* @param params.sortBy Zone: 'offensive', 'neutral' or 'defensive'. See `EdgeZones`.
|
|
343
|
+
* @example https://api-web.nhle.com/v1/edge/team-zone-time-top-10/es/offensive/20242025/2
|
|
344
|
+
*/
|
|
345
|
+
export async function teamZoneTimeTop10(ctx, { strength = EdgeStrengths.ALL, sortBy, ...params }) {
|
|
346
|
+
return getEdgeSegments(ctx, 'edge/team-zone-time-top-10', [strength, sortBy], params);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get the NHL EDGE top 10 teams by shot speed.
|
|
350
|
+
*
|
|
351
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'
|
|
352
|
+
* @param params.sortBy 'max', 'over-100', '90-99', '80-89' or '70-79' (attempts in mph)
|
|
353
|
+
* @example https://api-web.nhle.com/v1/edge/team-shot-speed-top-10/all/max/20252026/2
|
|
354
|
+
*/
|
|
355
|
+
export async function teamShotSpeedTop10(ctx, { positions = EdgePositions.ALL, sortBy, ...params }) {
|
|
356
|
+
return getEdgeSegments(ctx, 'edge/team-shot-speed-top-10', [positions, sortBy], params);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Get the NHL EDGE top 10 teams by shot location. `sortBy` comes before
|
|
360
|
+
* `category` in the URL (the NHL-API-Reference has them the other way round,
|
|
361
|
+
* which 404s).
|
|
362
|
+
*
|
|
363
|
+
* @param params.positions 'all' (default), 'forwards' or 'defense'. 'F' / 'D' are a 404 here.
|
|
364
|
+
* @param params.sortBy 'sog', 'goals' or 'shooting-pctg'
|
|
365
|
+
* @param params.category 'all' (default), 'high', 'mid' or 'long'
|
|
366
|
+
* @example https://api-web.nhle.com/v1/edge/team-shot-location-top-10/all/sog/all/20252026/2
|
|
367
|
+
*/
|
|
368
|
+
export async function teamShotLocationTop10(ctx, { positions = EdgePositions.ALL, sortBy, category = 'all', ...params }) {
|
|
369
|
+
return getEdgeSegments(ctx, 'edge/team-shot-location-top-10', [positions, sortBy, category], params);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get the NHL EDGE comparison statistics for a specific team.
|
|
373
|
+
*
|
|
374
|
+
* @param params.teamId NHL team id, e.g. 10
|
|
375
|
+
* @example await client.edge.teamComparison({ teamId: 10 })
|
|
376
|
+
*/
|
|
377
|
+
export async function teamComparison(ctx, params) {
|
|
378
|
+
return getEdge(ctx, 'edge/team-comparison', params.teamId, params);
|
|
379
|
+
}
|
|
380
|
+
// ========================
|
|
381
|
+
// LEAGUE ENDPOINTS
|
|
382
|
+
// ========================
|
|
383
|
+
/**
|
|
384
|
+
* Get the NHL EDGE "by the numbers" league highlights. Without a season this
|
|
385
|
+
* is the latest game night (`games`, `gameDate` and the nightly leaders);
|
|
386
|
+
* with a season it is the season bests (hardest shot, top speed, longest
|
|
387
|
+
* distance in a game).
|
|
388
|
+
*
|
|
389
|
+
* @example https://api-web.nhle.com/v1/edge/by-the-numbers/now
|
|
390
|
+
*/
|
|
391
|
+
export async function byTheNumbers(ctx, params = {}) {
|
|
392
|
+
return getEdge(ctx, 'edge/by-the-numbers', undefined, params);
|
|
393
|
+
}
|
|
160
394
|
export const edgeApi = {
|
|
161
395
|
skaterDetail,
|
|
162
396
|
skaterShotSpeedDetail,
|
|
@@ -181,4 +415,19 @@ export const edgeApi = {
|
|
|
181
415
|
teamLanding,
|
|
182
416
|
teamShotSpeedDetail,
|
|
183
417
|
teamSkatingSpeedDetail,
|
|
418
|
+
skaterDistanceTop10,
|
|
419
|
+
skaterSpeedTop10,
|
|
420
|
+
skaterZoneTimeTop10,
|
|
421
|
+
skaterShotSpeedTop10,
|
|
422
|
+
skaterShotLocationTop10,
|
|
423
|
+
goalie5v5Top10,
|
|
424
|
+
goalieShotLocationTop10,
|
|
425
|
+
goalieSavePercentageTop10,
|
|
426
|
+
teamSkatingDistanceTop10,
|
|
427
|
+
teamSkatingSpeedTop10,
|
|
428
|
+
teamZoneTimeTop10,
|
|
429
|
+
teamShotSpeedTop10,
|
|
430
|
+
teamShotLocationTop10,
|
|
431
|
+
teamComparison,
|
|
432
|
+
byTheNumbers,
|
|
184
433
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type { Boxscore, DailyScores, GameLanding, GameStory, PlayByPlay, RightRail, ShiftChart } from '#src/types/index.mjs';
|
|
2
|
+
import type { Boxscore, DailyScores, GameLanding, GameMeta, GameStory, PlayByPlay, PlayReplay, RightRail, Scoreboard, ShiftChart, WscPlay } from '#src/types/index.mjs';
|
|
3
3
|
import type { Id } from '#src/utils.mjs';
|
|
4
4
|
/**
|
|
5
5
|
* Get the full boxscore for a specific NHL game, including team scores,
|
|
@@ -8,9 +8,9 @@ import type { Id } from '#src/utils.mjs';
|
|
|
8
8
|
* @param params.gameId Game id, e.g. 2023020280
|
|
9
9
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/boxscore
|
|
10
10
|
*/
|
|
11
|
-
export declare
|
|
11
|
+
export declare function boxscore(ctx: Context, { gameId }: {
|
|
12
12
|
gameId: Id;
|
|
13
|
-
})
|
|
13
|
+
}): Promise<Boxscore>;
|
|
14
14
|
/**
|
|
15
15
|
* Get the full play-by-play feed for a specific NHL game, containing every
|
|
16
16
|
* recorded event (shots, hits, faceoffs, goals, penalties...).
|
|
@@ -18,9 +18,9 @@ export declare const boxscore: (ctx: Context, { gameId }: {
|
|
|
18
18
|
* @param params.gameId Game id, e.g. 2023020280
|
|
19
19
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/play-by-play
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare function playByPlay(ctx: Context, { gameId }: {
|
|
22
22
|
gameId: Id;
|
|
23
|
-
})
|
|
23
|
+
}): Promise<PlayByPlay>;
|
|
24
24
|
/**
|
|
25
25
|
* Get the landing-page summary for a specific NHL game, including scoring by
|
|
26
26
|
* period, three stars and penalties.
|
|
@@ -28,9 +28,9 @@ export declare const playByPlay: (ctx: Context, { gameId }: {
|
|
|
28
28
|
* @param params.gameId Game id, e.g. 2023020280
|
|
29
29
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/landing
|
|
30
30
|
*/
|
|
31
|
-
export declare
|
|
31
|
+
export declare function matchUp(ctx: Context, { gameId }: {
|
|
32
32
|
gameId: Id;
|
|
33
|
-
})
|
|
33
|
+
}): Promise<GameLanding>;
|
|
34
34
|
/**
|
|
35
35
|
* Get scores and game states for all NHL games on a given date. Returns the
|
|
36
36
|
* current day's scores when no date is supplied.
|
|
@@ -38,9 +38,9 @@ export declare const matchUp: (ctx: Context, { gameId }: {
|
|
|
38
38
|
* @param params.date Date in YYYY-MM-DD format. Defaults to "now".
|
|
39
39
|
* @example https://api-web.nhle.com/v1/score/2023-10-15
|
|
40
40
|
*/
|
|
41
|
-
export declare
|
|
41
|
+
export declare function dailyScores(ctx: Context, { date }?: {
|
|
42
42
|
date?: string;
|
|
43
|
-
})
|
|
43
|
+
}): Promise<DailyScores>;
|
|
44
44
|
/**
|
|
45
45
|
* Get individual player shift data for a specific game, including start/end
|
|
46
46
|
* times and durations.
|
|
@@ -49,10 +49,10 @@ export declare const dailyScores: (ctx: Context, { date }?: {
|
|
|
49
49
|
* @param params.excludes Fields to exclude from the response. Defaults to ["eventDetails"].
|
|
50
50
|
* @example https://api.nhle.com/stats/rest/en/shiftcharts?cayenneExp=gameId=2023020280 and ...
|
|
51
51
|
*/
|
|
52
|
-
export declare
|
|
52
|
+
export declare function shiftChartData(ctx: Context, { gameId, excludes }: {
|
|
53
53
|
gameId: Id;
|
|
54
54
|
excludes?: string[];
|
|
55
|
-
})
|
|
55
|
+
}): Promise<ShiftChart>;
|
|
56
56
|
/**
|
|
57
57
|
* Get the season-series record and contextual stats for a specific game,
|
|
58
58
|
* including team season stats and last games.
|
|
@@ -60,9 +60,9 @@ export declare const shiftChartData: (ctx: Context, { gameId, excludes }: {
|
|
|
60
60
|
* @param params.gameId Game id, e.g. 2023020280
|
|
61
61
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/right-rail
|
|
62
62
|
*/
|
|
63
|
-
export declare
|
|
63
|
+
export declare function seasonSeriesMatchup(ctx: Context, { gameId }: {
|
|
64
64
|
gameId: Id;
|
|
65
|
-
})
|
|
65
|
+
}): Promise<RightRail>;
|
|
66
66
|
/**
|
|
67
67
|
* Get the narrative game story for a specific game, including scoring
|
|
68
68
|
* summaries, three stars and team game stats.
|
|
@@ -70,9 +70,53 @@ export declare const seasonSeriesMatchup: (ctx: Context, { gameId }: {
|
|
|
70
70
|
* @param params.gameId Game id, e.g. 2023020280
|
|
71
71
|
* @example https://api-web.nhle.com/v1/wsc/game-story/2023020280
|
|
72
72
|
*/
|
|
73
|
-
export declare
|
|
73
|
+
export declare function gameStory(ctx: Context, { gameId }: {
|
|
74
74
|
gameId: Id;
|
|
75
|
-
})
|
|
75
|
+
}): Promise<GameStory>;
|
|
76
|
+
/**
|
|
77
|
+
* Get the league scoreboard: every game in the week around a date, grouped by
|
|
78
|
+
* date. Returns the week around today when no date is supplied.
|
|
79
|
+
*
|
|
80
|
+
* @param params.date Date in YYYY-MM-DD format. Defaults to "now".
|
|
81
|
+
* @example https://api-web.nhle.com/v1/scoreboard/2023-10-15
|
|
82
|
+
*/
|
|
83
|
+
export declare function scoreboard(ctx: Context, { date }?: {
|
|
84
|
+
date?: string;
|
|
85
|
+
}): Promise<Scoreboard>;
|
|
86
|
+
/**
|
|
87
|
+
* Get the play-by-play feed nhl.com's game story widget uses. A bare array of
|
|
88
|
+
* plays, with a different play shape from `playByPlay`.
|
|
89
|
+
*
|
|
90
|
+
* @param params.gameId Game id, e.g. 2023020280
|
|
91
|
+
* @example https://api-web.nhle.com/v1/wsc/play-by-play/2023020280
|
|
92
|
+
*/
|
|
93
|
+
export declare function wscPlayByPlay(ctx: Context, { gameId }: {
|
|
94
|
+
gameId: Id;
|
|
95
|
+
}): Promise<WscPlay[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the replay card for one play-by-play event: the game header, plus a
|
|
98
|
+
* `goal` object (scorer, assists, highlight clip and the `pptReplayUrl`
|
|
99
|
+
* puck-and-player-tracking link) when the event is a goal. Any event id works.
|
|
100
|
+
*
|
|
101
|
+
* @experimental Feeds an nhl.com widget; the shape may change without notice.
|
|
102
|
+
* @param params.gameId Game id, e.g. 2023020280
|
|
103
|
+
* @param params.eventNumber The play's `eventId` from `playByPlay`, e.g. 193
|
|
104
|
+
* @example https://api-web.nhle.com/v1/ppt-replay/2023020280/193
|
|
105
|
+
*/
|
|
106
|
+
export declare function playReplay(ctx: Context, { gameId, eventNumber }: {
|
|
107
|
+
gameId: Id;
|
|
108
|
+
eventNumber: Id;
|
|
109
|
+
}): Promise<PlayReplay>;
|
|
110
|
+
/**
|
|
111
|
+
* Get the metadata nhl.com uses to render a game page: the two teams, the
|
|
112
|
+
* season state and the game state.
|
|
113
|
+
*
|
|
114
|
+
* @param params.gameId Game id, e.g. 2023020280
|
|
115
|
+
* @example https://api-web.nhle.com/v1/meta/game/2023020280
|
|
116
|
+
*/
|
|
117
|
+
export declare function gameMeta(ctx: Context, { gameId }: {
|
|
118
|
+
gameId: Id;
|
|
119
|
+
}): Promise<GameMeta>;
|
|
76
120
|
export declare const gameCenterApi: {
|
|
77
121
|
readonly boxscore: typeof boxscore;
|
|
78
122
|
readonly playByPlay: typeof playByPlay;
|
|
@@ -81,4 +125,8 @@ export declare const gameCenterApi: {
|
|
|
81
125
|
readonly shiftChartData: typeof shiftChartData;
|
|
82
126
|
readonly seasonSeriesMatchup: typeof seasonSeriesMatchup;
|
|
83
127
|
readonly gameStory: typeof gameStory;
|
|
128
|
+
readonly scoreboard: typeof scoreboard;
|
|
129
|
+
readonly wscPlayByPlay: typeof wscPlayByPlay;
|
|
130
|
+
readonly playReplay: typeof playReplay;
|
|
131
|
+
readonly gameMeta: typeof gameMeta;
|
|
84
132
|
};
|