nhl-api-ts 0.1.0 → 0.2.1
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 +31 -6
- package/dist/api/edge.d.mts +25 -24
- package/dist/api/edge.mjs +69 -23
- package/dist/api/game-center.d.mts +16 -15
- package/dist/api/game-center.mjs +20 -8
- package/dist/api/helpers.d.mts +8 -7
- package/dist/api/helpers.mjs +6 -6
- package/dist/api/misc.d.mts +6 -6
- package/dist/api/misc.mjs +15 -5
- package/dist/api/players.d.mts +6 -5
- package/dist/api/players.mjs +6 -2
- package/dist/api/query/builder.d.mts +2 -0
- package/dist/api/query/builder.mjs +3 -1
- package/dist/api/query/index.d.mts +2 -2
- package/dist/api/query/index.mjs +1 -1
- package/dist/api/query/sorting/goalie-sorts.d.mts +55 -0
- package/dist/api/query/sorting/goalie-sorts.mjs +43 -48
- package/dist/api/query/sorting/sorting-options.d.mts +125 -0
- package/dist/api/query/sorting/sorting-options.mjs +3 -2
- package/dist/api/schedule.d.mts +22 -21
- package/dist/api/schedule.mjs +26 -14
- package/dist/api/standings.d.mts +5 -4
- package/dist/api/standings.mjs +4 -4
- package/dist/api/stats.d.mts +22 -17
- package/dist/api/stats.mjs +38 -16
- package/dist/api/teams.d.mts +9 -8
- package/dist/api/teams.mjs +10 -6
- package/dist/cli/colors.d.mts +2 -2
- package/dist/cli/colors.mjs +6 -2
- package/dist/cli/commands.mjs +36 -26
- package/dist/cli/run.mjs +7 -5
- package/dist/http-client.mjs +2 -2
- package/dist/index.d.mts +2 -1
- package/dist/nhl-client.d.mts +14 -10
- package/dist/nhl-client.mjs +9 -7
- package/dist/types/common.d.mts +80 -0
- package/dist/types/common.mjs +2 -0
- package/dist/types/edge.d.mts +1024 -0
- package/dist/types/edge.mjs +1 -0
- package/dist/types/game-center.d.mts +1137 -0
- package/dist/types/game-center.mjs +1 -0
- package/dist/types/helpers.d.mts +17 -0
- package/dist/types/helpers.mjs +1 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/misc.d.mts +68 -0
- package/dist/types/misc.mjs +2 -0
- package/dist/types/players.d.mts +41 -0
- package/dist/types/players.mjs +1 -0
- package/dist/types/schedule.d.mts +428 -0
- package/dist/types/schedule.mjs +1 -0
- package/dist/types/standings.d.mts +103 -0
- package/dist/types/standings.mjs +1 -0
- package/dist/types/stats.d.mts +1082 -0
- package/dist/types/stats.mjs +1 -0
- package/dist/types/teams.d.mts +29 -0
- package/dist/types/teams.mjs +1 -0
- package/dist/utils.d.mts +1 -2
- package/dist/utils.mjs +3 -1
- package/package.json +7 -20
- package/dist/api/query/errors.d.mts +0 -3
- package/dist/api/query/errors.mjs +0 -6
- package/dist/api/query/filters/base.d.mts +0 -4
- package/dist/api/query/filters/base.mjs +0 -2
- package/dist/api/query/filters/decision.d.mts +0 -13
- package/dist/api/query/filters/decision.mjs +0 -26
- package/dist/api/query/filters/draft.d.mts +0 -15
- package/dist/api/query/filters/draft.mjs +0 -27
- package/dist/api/query/filters/experience.d.mts +0 -9
- package/dist/api/query/filters/experience.mjs +0 -17
- package/dist/api/query/filters/franchise.d.mts +0 -9
- package/dist/api/query/filters/franchise.mjs +0 -15
- package/dist/api/query/filters/game-type.d.mts +0 -10
- package/dist/api/query/filters/game-type.mjs +0 -16
- package/dist/api/query/filters/goalie-sorts.d.mts +0 -3
- package/dist/api/query/filters/goalie-sorts.mjs +0 -55
- package/dist/api/query/filters/home-road.d.mts +0 -9
- package/dist/api/query/filters/home-road.mjs +0 -16
- package/dist/api/query/filters/index.d.mts +0 -14
- package/dist/api/query/filters/index.mjs +0 -14
- package/dist/api/query/filters/nationality.d.mts +0 -12
- package/dist/api/query/filters/nationality.mjs +0 -19
- package/dist/api/query/filters/opponent.d.mts +0 -10
- package/dist/api/query/filters/opponent.mjs +0 -16
- package/dist/api/query/filters/position.d.mts +0 -16
- package/dist/api/query/filters/position.mjs +0 -28
- package/dist/api/query/filters/season.d.mts +0 -14
- package/dist/api/query/filters/season.mjs +0 -24
- package/dist/api/query/filters/shoot-catch.d.mts +0 -9
- package/dist/api/query/filters/shoot-catch.mjs +0 -16
- package/dist/api/query/filters/status.d.mts +0 -20
- package/dist/api/query/filters/status.mjs +0 -28
- package/dist/logging.d.mts +0 -14
- package/dist/logging.mjs +0 -13
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Every SDK method is also available as a CLI command.
|
|
|
6
6
|
|
|
7
7
|
- Zero runtime dependencies (uses the built-in `fetch`)
|
|
8
8
|
- Node.js >= 24, ESM only
|
|
9
|
-
- Fully typed
|
|
9
|
+
- Fully typed: every response has a named interface you can [extend](docs/recipes/extending-response-types.md)
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
@@ -15,7 +15,8 @@ Every SDK method is also available as a CLI command.
|
|
|
15
15
|
- [Recipes](docs/recipes/): [filtered stats](docs/recipes/filter-skater-stats.md),
|
|
16
16
|
[pagination](docs/recipes/paginate-stats.md), [live scores](docs/recipes/live-scores.md),
|
|
17
17
|
[season-wide data](docs/recipes/season-wide-data.md), [retries](docs/recipes/retries.md),
|
|
18
|
-
[CLI + jq](docs/recipes/cli-and-jq.md), [testing](docs/recipes/testing.md)
|
|
18
|
+
[CLI + jq](docs/recipes/cli-and-jq.md), [testing](docs/recipes/testing.md),
|
|
19
|
+
[extending response types](docs/recipes/extending-response-types.md)
|
|
19
20
|
- [Examples](examples/): runnable scripts
|
|
20
21
|
- [API report](api-report.md): the full public TypeScript API
|
|
21
22
|
- [OpenAPI](openapi.yaml): every HTTP path the SDK calls
|
|
@@ -181,6 +182,25 @@ Skater report types: `summary`, `bios`, `faceoffpercentages`, `faceoffwins`,
|
|
|
181
182
|
`powerplay`, `puckPossessions`, `summaryshooting`, `percentages`,
|
|
182
183
|
`scoringRates`, `scoringpergame`, `shootout`, `shottype`, `timeonice`.
|
|
183
184
|
|
|
185
|
+
## Extending the types
|
|
186
|
+
|
|
187
|
+
Response types come from real API responses, and the NHL adds fields without
|
|
188
|
+
notice. Every object type is an `interface`, so you can add what's missing with
|
|
189
|
+
module augmentation:
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
declare module 'nhl-api-ts' {
|
|
193
|
+
interface Boxscore {
|
|
194
|
+
someNewField?: string;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
New play types and report types are added through registries (`PlayTypes`,
|
|
200
|
+
`SkaterReportRows`, `GoalieReportRows`). See
|
|
201
|
+
[Extending response types](docs/recipes/extending-response-types.md) for those
|
|
202
|
+
and for the one-off cast.
|
|
203
|
+
|
|
184
204
|
## Errors
|
|
185
205
|
|
|
186
206
|
HTTP failures throw exceptions that all extend `NHLApiException`, which has
|
|
@@ -270,21 +290,26 @@ nhl-api-ts teams teams --compact | jq -r '.[].abbr'
|
|
|
270
290
|
|
|
271
291
|
## Development
|
|
272
292
|
|
|
293
|
+
This package lives in a pnpm workspace. Run these from the
|
|
294
|
+
[repository root](https://github.com/andrewangelle/nhl-api-ts):
|
|
295
|
+
|
|
273
296
|
```bash
|
|
274
297
|
pnpm install
|
|
275
298
|
pnpm test # node:test, runs the TypeScript sources directly
|
|
276
299
|
pnpm typecheck
|
|
277
300
|
pnpm lint:check
|
|
278
|
-
pnpm build # emits dist/
|
|
301
|
+
pnpm build # emits packages/nhl-api-ts/dist/
|
|
279
302
|
```
|
|
280
303
|
|
|
281
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
282
|
-
|
|
304
|
+
See [CONTRIBUTING.md](https://github.com/andrewangelle/nhl-api-ts/blob/main/CONTRIBUTING.md)
|
|
305
|
+
for the full set of checks, and
|
|
306
|
+
[AGENTS.md](https://github.com/andrewangelle/nhl-api-ts/blob/main/AGENTS.md) for
|
|
307
|
+
repository conventions.
|
|
283
308
|
|
|
284
309
|
Try the CLI from source:
|
|
285
310
|
|
|
286
311
|
```bash
|
|
287
|
-
node --conditions=source src/cli.mts --help
|
|
312
|
+
node --conditions=source packages/nhl-api-ts/src/cli.mts --help
|
|
288
313
|
```
|
|
289
314
|
|
|
290
315
|
## Credits
|
package/dist/api/edge.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CatGoalieDetail, CatSkaterDetail, Goalie5v5Detail, GoalieComparison, GoalieDetail, GoalieLanding, GoalieSavePercentageDetail, GoalieShotLocationDetail, SkaterComparison, SkaterDetail, SkaterLanding, SkaterShotLocationDetail, SkaterShotSpeedDetail, SkaterSkatingDistanceDetail, SkaterSkatingSpeedDetail, SkaterZoneTime, TeamDetail, TeamLanding, TeamShotLocationDetail, TeamShotSpeedDetail, TeamSkatingDistanceDetail, TeamSkatingSpeedDetail, TeamZoneTimeDetails } from '#src/types/index.mjs';
|
|
3
|
+
import type { Id } from '#src/utils.mjs';
|
|
3
4
|
export interface EdgeSeasonParams {
|
|
4
5
|
/** Season in YYYYYYYY format, e.g. 20232024. Defaults to the current season ("now"). */
|
|
5
6
|
season?: Id;
|
|
@@ -19,139 +20,139 @@ export interface EdgeTeamParams extends EdgeSeasonParams {
|
|
|
19
20
|
*
|
|
20
21
|
* @example await client.edge.skaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
21
22
|
*/
|
|
22
|
-
export declare
|
|
23
|
+
export declare function skaterDetail(ctx: Context, params: EdgePlayerParams): Promise<SkaterDetail>;
|
|
23
24
|
/**
|
|
24
25
|
* Get NHL EDGE shot speed details for a specific skater.
|
|
25
26
|
*
|
|
26
27
|
* @example await client.edge.skaterShotSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
27
28
|
*/
|
|
28
|
-
export declare
|
|
29
|
+
export declare function skaterShotSpeedDetail(ctx: Context, params: EdgePlayerParams): Promise<SkaterShotSpeedDetail>;
|
|
29
30
|
/**
|
|
30
31
|
* Get NHL EDGE skating speed details for a specific skater.
|
|
31
32
|
*
|
|
32
33
|
* @example await client.edge.skaterSkatingSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
33
34
|
*/
|
|
34
|
-
export declare
|
|
35
|
+
export declare function skaterSkatingSpeedDetail(ctx: Context, params: EdgePlayerParams): Promise<SkaterSkatingSpeedDetail>;
|
|
35
36
|
/**
|
|
36
37
|
* Get NHL EDGE shot location details for a specific skater.
|
|
37
38
|
*
|
|
38
39
|
* @example await client.edge.skaterShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
39
40
|
*/
|
|
40
|
-
export declare
|
|
41
|
+
export declare function skaterShotLocationDetail(ctx: Context, params: EdgePlayerParams): Promise<SkaterShotLocationDetail>;
|
|
41
42
|
/**
|
|
42
43
|
* Get NHL EDGE skating distance details for a specific skater.
|
|
43
44
|
*
|
|
44
45
|
* @example await client.edge.skaterSkatingDistanceDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
45
46
|
*/
|
|
46
|
-
export declare
|
|
47
|
+
export declare function skaterSkatingDistanceDetail(ctx: Context, params: EdgePlayerParams): Promise<SkaterSkatingDistanceDetail>;
|
|
47
48
|
/**
|
|
48
49
|
* Get NHL EDGE comparison statistics for a specific skater.
|
|
49
50
|
*
|
|
50
51
|
* @example await client.edge.skaterComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
51
52
|
*/
|
|
52
|
-
export declare
|
|
53
|
+
export declare function skaterComparison(ctx: Context, params: EdgePlayerParams): Promise<SkaterComparison>;
|
|
53
54
|
/**
|
|
54
55
|
* Get NHL EDGE zone time details for a specific skater.
|
|
55
56
|
*
|
|
56
57
|
* @example await client.edge.skaterZoneTime({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
57
58
|
*/
|
|
58
|
-
export declare
|
|
59
|
+
export declare function skaterZoneTime(ctx: Context, params: EdgePlayerParams): Promise<SkaterZoneTime>;
|
|
59
60
|
/**
|
|
60
61
|
* Get NHL EDGE skater landing page data.
|
|
61
62
|
*
|
|
62
63
|
* @example await client.edge.skaterLanding({ season: '20232024' })
|
|
63
64
|
*/
|
|
64
|
-
export declare
|
|
65
|
+
export declare function skaterLanding(ctx: Context, params?: EdgeSeasonParams): Promise<SkaterLanding>;
|
|
65
66
|
/**
|
|
66
67
|
* Get NHL CAT (Catch All Tracking) EDGE skater details.
|
|
67
68
|
*
|
|
68
69
|
* @example await client.edge.catSkaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
69
70
|
*/
|
|
70
|
-
export declare
|
|
71
|
+
export declare function catSkaterDetail(ctx: Context, params: EdgePlayerParams): Promise<CatSkaterDetail>;
|
|
71
72
|
/**
|
|
72
73
|
* Get NHL EDGE goalie detail statistics for a specific player.
|
|
73
74
|
*
|
|
74
75
|
* @example await client.edge.goalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
75
76
|
*/
|
|
76
|
-
export declare
|
|
77
|
+
export declare function goalieDetail(ctx: Context, params: EdgePlayerParams): Promise<GoalieDetail>;
|
|
77
78
|
/**
|
|
78
79
|
* Get NHL EDGE shot location details for a specific goalie.
|
|
79
80
|
*
|
|
80
81
|
* @example await client.edge.goalieShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
81
82
|
*/
|
|
82
|
-
export declare
|
|
83
|
+
export declare function goalieShotLocationDetail(ctx: Context, params: EdgePlayerParams): Promise<GoalieShotLocationDetail>;
|
|
83
84
|
/**
|
|
84
85
|
* Get NHL EDGE 5v5 performance details for a specific goalie.
|
|
85
86
|
*
|
|
86
87
|
* @example await client.edge.goalie5v5Detail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
87
88
|
*/
|
|
88
|
-
export declare
|
|
89
|
+
export declare function goalie5v5Detail(ctx: Context, params: EdgePlayerParams): Promise<Goalie5v5Detail>;
|
|
89
90
|
/**
|
|
90
91
|
* Get NHL EDGE comparison statistics for a specific goalie.
|
|
91
92
|
*
|
|
92
93
|
* @example await client.edge.goalieComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
93
94
|
*/
|
|
94
|
-
export declare
|
|
95
|
+
export declare function goalieComparison(ctx: Context, params: EdgePlayerParams): Promise<GoalieComparison>;
|
|
95
96
|
/**
|
|
96
97
|
* Get NHL EDGE save percentage details for a specific goalie.
|
|
97
98
|
*
|
|
98
99
|
* @example await client.edge.goalieSavePercentageDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
99
100
|
*/
|
|
100
|
-
export declare
|
|
101
|
+
export declare function goalieSavePercentageDetail(ctx: Context, params: EdgePlayerParams): Promise<GoalieSavePercentageDetail>;
|
|
101
102
|
/**
|
|
102
103
|
* Get NHL EDGE goalie landing page data.
|
|
103
104
|
*
|
|
104
105
|
* @example await client.edge.goalieLanding({ season: '20232024' })
|
|
105
106
|
*/
|
|
106
|
-
export declare
|
|
107
|
+
export declare function goalieLanding(ctx: Context, params?: EdgeSeasonParams): Promise<GoalieLanding>;
|
|
107
108
|
/**
|
|
108
109
|
* Get NHL CAT (Catch All Tracking) EDGE goalie details.
|
|
109
110
|
*
|
|
110
111
|
* @example await client.edge.catGoalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
111
112
|
*/
|
|
112
|
-
export declare
|
|
113
|
+
export declare function catGoalieDetail(ctx: Context, params: EdgePlayerParams): Promise<CatGoalieDetail>;
|
|
113
114
|
/**
|
|
114
115
|
* Get NHL EDGE team detail statistics for a specific team.
|
|
115
116
|
*
|
|
116
117
|
* @example await client.edge.teamDetail({ teamId: 10 })
|
|
117
118
|
*/
|
|
118
|
-
export declare
|
|
119
|
+
export declare function teamDetail(ctx: Context, params: EdgeTeamParams): Promise<TeamDetail>;
|
|
119
120
|
/**
|
|
120
121
|
* Get NHL EDGE skating distance details for a specific team.
|
|
121
122
|
*
|
|
122
123
|
* @example await client.edge.teamSkatingDistanceDetail({ teamId: 10 })
|
|
123
124
|
*/
|
|
124
|
-
export declare
|
|
125
|
+
export declare function teamSkatingDistanceDetail(ctx: Context, params: EdgeTeamParams): Promise<TeamSkatingDistanceDetail>;
|
|
125
126
|
/**
|
|
126
127
|
* Get NHL EDGE zone time details for a specific team.
|
|
127
128
|
*
|
|
128
129
|
* @example await client.edge.teamZoneTimeDetails({ teamId: 10 })
|
|
129
130
|
*/
|
|
130
|
-
export declare
|
|
131
|
+
export declare function teamZoneTimeDetails(ctx: Context, params: EdgeTeamParams): Promise<TeamZoneTimeDetails>;
|
|
131
132
|
/**
|
|
132
133
|
* Get NHL EDGE shot location details for a specific team.
|
|
133
134
|
*
|
|
134
135
|
* @example await client.edge.teamShotLocationDetail({ teamId: 10 })
|
|
135
136
|
*/
|
|
136
|
-
export declare
|
|
137
|
+
export declare function teamShotLocationDetail(ctx: Context, params: EdgeTeamParams): Promise<TeamShotLocationDetail>;
|
|
137
138
|
/**
|
|
138
139
|
* Get NHL EDGE team landing page data.
|
|
139
140
|
*
|
|
140
141
|
* @example await client.edge.teamLanding({ season: '20232024' })
|
|
141
142
|
*/
|
|
142
|
-
export declare
|
|
143
|
+
export declare function teamLanding(ctx: Context, params?: EdgeSeasonParams): Promise<TeamLanding>;
|
|
143
144
|
/**
|
|
144
145
|
* Get NHL EDGE shot speed details for a specific team.
|
|
145
146
|
*
|
|
146
147
|
* @example await client.edge.teamShotSpeedDetail({ teamId: 10 })
|
|
147
148
|
*/
|
|
148
|
-
export declare
|
|
149
|
+
export declare function teamShotSpeedDetail(ctx: Context, params: EdgeTeamParams): Promise<TeamShotSpeedDetail>;
|
|
149
150
|
/**
|
|
150
151
|
* Get NHL EDGE skating speed details for a specific team.
|
|
151
152
|
*
|
|
152
153
|
* @example await client.edge.teamSkatingSpeedDetail({ teamId: 10 })
|
|
153
154
|
*/
|
|
154
|
-
export declare
|
|
155
|
+
export declare function teamSkatingSpeedDetail(ctx: Context, params: EdgeTeamParams): Promise<TeamSkatingSpeedDetail>;
|
|
155
156
|
export declare const edgeApi: {
|
|
156
157
|
readonly skaterDetail: typeof skaterDetail;
|
|
157
158
|
readonly skaterShotSpeedDetail: typeof skaterShotSpeedDetail;
|
package/dist/api/edge.mjs
CHANGED
|
@@ -18,55 +18,73 @@ async function getEdge(ctx, path, id, params) {
|
|
|
18
18
|
*
|
|
19
19
|
* @example await client.edge.skaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export async function skaterDetail(ctx, params) {
|
|
22
|
+
return getEdge(ctx, 'edge/skater-detail', params.playerId, params);
|
|
23
|
+
}
|
|
22
24
|
/**
|
|
23
25
|
* Get NHL EDGE shot speed details for a specific skater.
|
|
24
26
|
*
|
|
25
27
|
* @example await client.edge.skaterShotSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
26
28
|
*/
|
|
27
|
-
export
|
|
29
|
+
export async function skaterShotSpeedDetail(ctx, params) {
|
|
30
|
+
return getEdge(ctx, 'edge/skater-shot-speed-detail', params.playerId, params);
|
|
31
|
+
}
|
|
28
32
|
/**
|
|
29
33
|
* Get NHL EDGE skating speed details for a specific skater.
|
|
30
34
|
*
|
|
31
35
|
* @example await client.edge.skaterSkatingSpeedDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
32
36
|
*/
|
|
33
|
-
export
|
|
37
|
+
export async function skaterSkatingSpeedDetail(ctx, params) {
|
|
38
|
+
return getEdge(ctx, 'edge/skater-skating-speed-detail', params.playerId, params);
|
|
39
|
+
}
|
|
34
40
|
/**
|
|
35
41
|
* Get NHL EDGE shot location details for a specific skater.
|
|
36
42
|
*
|
|
37
43
|
* @example await client.edge.skaterShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
38
44
|
*/
|
|
39
|
-
export
|
|
45
|
+
export async function skaterShotLocationDetail(ctx, params) {
|
|
46
|
+
return getEdge(ctx, 'edge/skater-shot-location-detail', params.playerId, params);
|
|
47
|
+
}
|
|
40
48
|
/**
|
|
41
49
|
* Get NHL EDGE skating distance details for a specific skater.
|
|
42
50
|
*
|
|
43
51
|
* @example await client.edge.skaterSkatingDistanceDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
44
52
|
*/
|
|
45
|
-
export
|
|
53
|
+
export async function skaterSkatingDistanceDetail(ctx, params) {
|
|
54
|
+
return getEdge(ctx, 'edge/skater-skating-distance-detail', params.playerId, params);
|
|
55
|
+
}
|
|
46
56
|
/**
|
|
47
57
|
* Get NHL EDGE comparison statistics for a specific skater.
|
|
48
58
|
*
|
|
49
59
|
* @example await client.edge.skaterComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
50
60
|
*/
|
|
51
|
-
export
|
|
61
|
+
export async function skaterComparison(ctx, params) {
|
|
62
|
+
return getEdge(ctx, 'edge/skater-comparison', params.playerId, params);
|
|
63
|
+
}
|
|
52
64
|
/**
|
|
53
65
|
* Get NHL EDGE zone time details for a specific skater.
|
|
54
66
|
*
|
|
55
67
|
* @example await client.edge.skaterZoneTime({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
56
68
|
*/
|
|
57
|
-
export
|
|
69
|
+
export async function skaterZoneTime(ctx, params) {
|
|
70
|
+
return getEdge(ctx, 'edge/skater-zone-time', params.playerId, params);
|
|
71
|
+
}
|
|
58
72
|
/**
|
|
59
73
|
* Get NHL EDGE skater landing page data.
|
|
60
74
|
*
|
|
61
75
|
* @example await client.edge.skaterLanding({ season: '20232024' })
|
|
62
76
|
*/
|
|
63
|
-
export
|
|
77
|
+
export async function skaterLanding(ctx, params = {}) {
|
|
78
|
+
return getEdge(ctx, 'edge/skater-landing', undefined, params);
|
|
79
|
+
}
|
|
64
80
|
/**
|
|
65
81
|
* Get NHL CAT (Catch All Tracking) EDGE skater details.
|
|
66
82
|
*
|
|
67
83
|
* @example await client.edge.catSkaterDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
68
84
|
*/
|
|
69
|
-
export
|
|
85
|
+
export async function catSkaterDetail(ctx, params) {
|
|
86
|
+
return getEdge(ctx, 'cat/edge/skater-detail', params.playerId, params);
|
|
87
|
+
}
|
|
70
88
|
// ========================
|
|
71
89
|
// GOALIE ENDPOINTS
|
|
72
90
|
// ========================
|
|
@@ -75,43 +93,57 @@ export const catSkaterDetail = async (ctx, params) => getEdge(ctx, 'cat/edge/ska
|
|
|
75
93
|
*
|
|
76
94
|
* @example await client.edge.goalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
77
95
|
*/
|
|
78
|
-
export
|
|
96
|
+
export async function goalieDetail(ctx, params) {
|
|
97
|
+
return getEdge(ctx, 'edge/goalie-detail', params.playerId, params);
|
|
98
|
+
}
|
|
79
99
|
/**
|
|
80
100
|
* Get NHL EDGE shot location details for a specific goalie.
|
|
81
101
|
*
|
|
82
102
|
* @example await client.edge.goalieShotLocationDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
83
103
|
*/
|
|
84
|
-
export
|
|
104
|
+
export async function goalieShotLocationDetail(ctx, params) {
|
|
105
|
+
return getEdge(ctx, 'edge/goalie-shot-location-detail', params.playerId, params);
|
|
106
|
+
}
|
|
85
107
|
/**
|
|
86
108
|
* Get NHL EDGE 5v5 performance details for a specific goalie.
|
|
87
109
|
*
|
|
88
110
|
* @example await client.edge.goalie5v5Detail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
89
111
|
*/
|
|
90
|
-
export
|
|
112
|
+
export async function goalie5v5Detail(ctx, params) {
|
|
113
|
+
return getEdge(ctx, 'edge/goalie-5v5-detail', params.playerId, params);
|
|
114
|
+
}
|
|
91
115
|
/**
|
|
92
116
|
* Get NHL EDGE comparison statistics for a specific goalie.
|
|
93
117
|
*
|
|
94
118
|
* @example await client.edge.goalieComparison({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
95
119
|
*/
|
|
96
|
-
export
|
|
120
|
+
export async function goalieComparison(ctx, params) {
|
|
121
|
+
return getEdge(ctx, 'edge/goalie-comparison', params.playerId, params);
|
|
122
|
+
}
|
|
97
123
|
/**
|
|
98
124
|
* Get NHL EDGE save percentage details for a specific goalie.
|
|
99
125
|
*
|
|
100
126
|
* @example await client.edge.goalieSavePercentageDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
101
127
|
*/
|
|
102
|
-
export
|
|
128
|
+
export async function goalieSavePercentageDetail(ctx, params) {
|
|
129
|
+
return getEdge(ctx, 'edge/goalie-save-percentage-detail', params.playerId, params);
|
|
130
|
+
}
|
|
103
131
|
/**
|
|
104
132
|
* Get NHL EDGE goalie landing page data.
|
|
105
133
|
*
|
|
106
134
|
* @example await client.edge.goalieLanding({ season: '20232024' })
|
|
107
135
|
*/
|
|
108
|
-
export
|
|
136
|
+
export async function goalieLanding(ctx, params = {}) {
|
|
137
|
+
return getEdge(ctx, 'edge/goalie-landing', undefined, params);
|
|
138
|
+
}
|
|
109
139
|
/**
|
|
110
140
|
* Get NHL CAT (Catch All Tracking) EDGE goalie details.
|
|
111
141
|
*
|
|
112
142
|
* @example await client.edge.catGoalieDetail({ playerId: 8478402, season: '20232024', gameType: 2 })
|
|
113
143
|
*/
|
|
114
|
-
export
|
|
144
|
+
export async function catGoalieDetail(ctx, params) {
|
|
145
|
+
return getEdge(ctx, 'cat/edge/goalie-detail', params.playerId, params);
|
|
146
|
+
}
|
|
115
147
|
// ========================
|
|
116
148
|
// TEAM ENDPOINTS
|
|
117
149
|
// ========================
|
|
@@ -120,43 +152,57 @@ export const catGoalieDetail = async (ctx, params) => getEdge(ctx, 'cat/edge/goa
|
|
|
120
152
|
*
|
|
121
153
|
* @example await client.edge.teamDetail({ teamId: 10 })
|
|
122
154
|
*/
|
|
123
|
-
export
|
|
155
|
+
export async function teamDetail(ctx, params) {
|
|
156
|
+
return getEdge(ctx, 'edge/team-detail', params.teamId, params);
|
|
157
|
+
}
|
|
124
158
|
/**
|
|
125
159
|
* Get NHL EDGE skating distance details for a specific team.
|
|
126
160
|
*
|
|
127
161
|
* @example await client.edge.teamSkatingDistanceDetail({ teamId: 10 })
|
|
128
162
|
*/
|
|
129
|
-
export
|
|
163
|
+
export async function teamSkatingDistanceDetail(ctx, params) {
|
|
164
|
+
return getEdge(ctx, 'edge/team-skating-distance-detail', params.teamId, params);
|
|
165
|
+
}
|
|
130
166
|
/**
|
|
131
167
|
* Get NHL EDGE zone time details for a specific team.
|
|
132
168
|
*
|
|
133
169
|
* @example await client.edge.teamZoneTimeDetails({ teamId: 10 })
|
|
134
170
|
*/
|
|
135
|
-
export
|
|
171
|
+
export async function teamZoneTimeDetails(ctx, params) {
|
|
172
|
+
return getEdge(ctx, 'edge/team-zone-time-details', params.teamId, params);
|
|
173
|
+
}
|
|
136
174
|
/**
|
|
137
175
|
* Get NHL EDGE shot location details for a specific team.
|
|
138
176
|
*
|
|
139
177
|
* @example await client.edge.teamShotLocationDetail({ teamId: 10 })
|
|
140
178
|
*/
|
|
141
|
-
export
|
|
179
|
+
export async function teamShotLocationDetail(ctx, params) {
|
|
180
|
+
return getEdge(ctx, 'edge/team-shot-location-detail', params.teamId, params);
|
|
181
|
+
}
|
|
142
182
|
/**
|
|
143
183
|
* Get NHL EDGE team landing page data.
|
|
144
184
|
*
|
|
145
185
|
* @example await client.edge.teamLanding({ season: '20232024' })
|
|
146
186
|
*/
|
|
147
|
-
export
|
|
187
|
+
export async function teamLanding(ctx, params = {}) {
|
|
188
|
+
return getEdge(ctx, 'edge/team-landing', undefined, params);
|
|
189
|
+
}
|
|
148
190
|
/**
|
|
149
191
|
* Get NHL EDGE shot speed details for a specific team.
|
|
150
192
|
*
|
|
151
193
|
* @example await client.edge.teamShotSpeedDetail({ teamId: 10 })
|
|
152
194
|
*/
|
|
153
|
-
export
|
|
195
|
+
export async function teamShotSpeedDetail(ctx, params) {
|
|
196
|
+
return getEdge(ctx, 'edge/team-shot-speed-detail', params.teamId, params);
|
|
197
|
+
}
|
|
154
198
|
/**
|
|
155
199
|
* Get NHL EDGE skating speed details for a specific team.
|
|
156
200
|
*
|
|
157
201
|
* @example await client.edge.teamSkatingSpeedDetail({ teamId: 10 })
|
|
158
202
|
*/
|
|
159
|
-
export
|
|
203
|
+
export async function teamSkatingSpeedDetail(ctx, params) {
|
|
204
|
+
return getEdge(ctx, 'edge/team-skating-speed-detail', params.teamId, params);
|
|
205
|
+
}
|
|
160
206
|
export const edgeApi = {
|
|
161
207
|
skaterDetail,
|
|
162
208
|
skaterShotSpeedDetail,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Boxscore, DailyScores, GameLanding, GameStory, PlayByPlay, RightRail, ShiftChart } from '#src/types/index.mjs';
|
|
3
|
+
import type { Id } from '#src/utils.mjs';
|
|
3
4
|
/**
|
|
4
5
|
* Get the full boxscore for a specific NHL game, including team scores,
|
|
5
6
|
* shots on goal, and per-player stats.
|
|
@@ -7,9 +8,9 @@ import type { Id, JsonObject } from '#src/utils.mjs';
|
|
|
7
8
|
* @param params.gameId Game id, e.g. 2023020280
|
|
8
9
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/boxscore
|
|
9
10
|
*/
|
|
10
|
-
export declare
|
|
11
|
+
export declare function boxscore(ctx: Context, { gameId }: {
|
|
11
12
|
gameId: Id;
|
|
12
|
-
})
|
|
13
|
+
}): Promise<Boxscore>;
|
|
13
14
|
/**
|
|
14
15
|
* Get the full play-by-play feed for a specific NHL game, containing every
|
|
15
16
|
* recorded event (shots, hits, faceoffs, goals, penalties...).
|
|
@@ -17,9 +18,9 @@ export declare const boxscore: (ctx: Context, { gameId }: {
|
|
|
17
18
|
* @param params.gameId Game id, e.g. 2023020280
|
|
18
19
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/play-by-play
|
|
19
20
|
*/
|
|
20
|
-
export declare
|
|
21
|
+
export declare function playByPlay(ctx: Context, { gameId }: {
|
|
21
22
|
gameId: Id;
|
|
22
|
-
})
|
|
23
|
+
}): Promise<PlayByPlay>;
|
|
23
24
|
/**
|
|
24
25
|
* Get the landing-page summary for a specific NHL game, including scoring by
|
|
25
26
|
* period, three stars and penalties.
|
|
@@ -27,9 +28,9 @@ export declare const playByPlay: (ctx: Context, { gameId }: {
|
|
|
27
28
|
* @param params.gameId Game id, e.g. 2023020280
|
|
28
29
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/landing
|
|
29
30
|
*/
|
|
30
|
-
export declare
|
|
31
|
+
export declare function matchUp(ctx: Context, { gameId }: {
|
|
31
32
|
gameId: Id;
|
|
32
|
-
})
|
|
33
|
+
}): Promise<GameLanding>;
|
|
33
34
|
/**
|
|
34
35
|
* Get scores and game states for all NHL games on a given date. Returns the
|
|
35
36
|
* current day's scores when no date is supplied.
|
|
@@ -37,9 +38,9 @@ export declare const matchUp: (ctx: Context, { gameId }: {
|
|
|
37
38
|
* @param params.date Date in YYYY-MM-DD format. Defaults to "now".
|
|
38
39
|
* @example https://api-web.nhle.com/v1/score/2023-10-15
|
|
39
40
|
*/
|
|
40
|
-
export declare
|
|
41
|
+
export declare function dailyScores(ctx: Context, { date }?: {
|
|
41
42
|
date?: string;
|
|
42
|
-
})
|
|
43
|
+
}): Promise<DailyScores>;
|
|
43
44
|
/**
|
|
44
45
|
* Get individual player shift data for a specific game, including start/end
|
|
45
46
|
* times and durations.
|
|
@@ -48,10 +49,10 @@ export declare const dailyScores: (ctx: Context, { date }?: {
|
|
|
48
49
|
* @param params.excludes Fields to exclude from the response. Defaults to ["eventDetails"].
|
|
49
50
|
* @example https://api.nhle.com/stats/rest/en/shiftcharts?cayenneExp=gameId=2023020280 and ...
|
|
50
51
|
*/
|
|
51
|
-
export declare
|
|
52
|
+
export declare function shiftChartData(ctx: Context, { gameId, excludes }: {
|
|
52
53
|
gameId: Id;
|
|
53
54
|
excludes?: string[];
|
|
54
|
-
})
|
|
55
|
+
}): Promise<ShiftChart>;
|
|
55
56
|
/**
|
|
56
57
|
* Get the season-series record and contextual stats for a specific game,
|
|
57
58
|
* including team season stats and last games.
|
|
@@ -59,9 +60,9 @@ export declare const shiftChartData: (ctx: Context, { gameId, excludes }: {
|
|
|
59
60
|
* @param params.gameId Game id, e.g. 2023020280
|
|
60
61
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/right-rail
|
|
61
62
|
*/
|
|
62
|
-
export declare
|
|
63
|
+
export declare function seasonSeriesMatchup(ctx: Context, { gameId }: {
|
|
63
64
|
gameId: Id;
|
|
64
|
-
})
|
|
65
|
+
}): Promise<RightRail>;
|
|
65
66
|
/**
|
|
66
67
|
* Get the narrative game story for a specific game, including scoring
|
|
67
68
|
* summaries, three stars and team game stats.
|
|
@@ -69,9 +70,9 @@ export declare const seasonSeriesMatchup: (ctx: Context, { gameId }: {
|
|
|
69
70
|
* @param params.gameId Game id, e.g. 2023020280
|
|
70
71
|
* @example https://api-web.nhle.com/v1/wsc/game-story/2023020280
|
|
71
72
|
*/
|
|
72
|
-
export declare
|
|
73
|
+
export declare function gameStory(ctx: Context, { gameId }: {
|
|
73
74
|
gameId: Id;
|
|
74
|
-
})
|
|
75
|
+
}): Promise<GameStory>;
|
|
75
76
|
export declare const gameCenterApi: {
|
|
76
77
|
readonly boxscore: typeof boxscore;
|
|
77
78
|
readonly playByPlay: typeof playByPlay;
|
package/dist/api/game-center.mjs
CHANGED
|
@@ -9,7 +9,9 @@ async function getWeb(ctx, resource) {
|
|
|
9
9
|
* @param params.gameId Game id, e.g. 2023020280
|
|
10
10
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/boxscore
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export async function boxscore(ctx, { gameId }) {
|
|
13
|
+
return getWeb(ctx, `gamecenter/${gameId}/boxscore`);
|
|
14
|
+
}
|
|
13
15
|
/**
|
|
14
16
|
* Get the full play-by-play feed for a specific NHL game, containing every
|
|
15
17
|
* recorded event (shots, hits, faceoffs, goals, penalties...).
|
|
@@ -17,7 +19,9 @@ export const boxscore = async (ctx, { gameId }) => getWeb(ctx, `gamecenter/${gam
|
|
|
17
19
|
* @param params.gameId Game id, e.g. 2023020280
|
|
18
20
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/play-by-play
|
|
19
21
|
*/
|
|
20
|
-
export
|
|
22
|
+
export async function playByPlay(ctx, { gameId }) {
|
|
23
|
+
return getWeb(ctx, `gamecenter/${gameId}/play-by-play`);
|
|
24
|
+
}
|
|
21
25
|
/**
|
|
22
26
|
* Get the landing-page summary for a specific NHL game, including scoring by
|
|
23
27
|
* period, three stars and penalties.
|
|
@@ -25,7 +29,9 @@ export const playByPlay = async (ctx, { gameId }) => getWeb(ctx, `gamecenter/${g
|
|
|
25
29
|
* @param params.gameId Game id, e.g. 2023020280
|
|
26
30
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/landing
|
|
27
31
|
*/
|
|
28
|
-
export
|
|
32
|
+
export async function matchUp(ctx, { gameId }) {
|
|
33
|
+
return getWeb(ctx, `gamecenter/${gameId}/landing`);
|
|
34
|
+
}
|
|
29
35
|
/**
|
|
30
36
|
* Get scores and game states for all NHL games on a given date. Returns the
|
|
31
37
|
* current day's scores when no date is supplied.
|
|
@@ -33,7 +39,9 @@ export const matchUp = async (ctx, { gameId }) => getWeb(ctx, `gamecenter/${game
|
|
|
33
39
|
* @param params.date Date in YYYY-MM-DD format. Defaults to "now".
|
|
34
40
|
* @example https://api-web.nhle.com/v1/score/2023-10-15
|
|
35
41
|
*/
|
|
36
|
-
export
|
|
42
|
+
export async function dailyScores(ctx, { date } = {}) {
|
|
43
|
+
return getWeb(ctx, `score/${date ? date : 'now'}`);
|
|
44
|
+
}
|
|
37
45
|
/**
|
|
38
46
|
* Get individual player shift data for a specific game, including start/end
|
|
39
47
|
* times and durations.
|
|
@@ -42,11 +50,11 @@ export const dailyScores = async (ctx, { date } = {}) => getWeb(ctx, `score/${da
|
|
|
42
50
|
* @param params.excludes Fields to exclude from the response. Defaults to ["eventDetails"].
|
|
43
51
|
* @example https://api.nhle.com/stats/rest/en/shiftcharts?cayenneExp=gameId=2023020280 and ...
|
|
44
52
|
*/
|
|
45
|
-
export
|
|
53
|
+
export async function shiftChartData(ctx, { gameId, excludes = ['eventDetails'] }) {
|
|
46
54
|
const excludeP = excludes.join(',');
|
|
47
55
|
const exprP = `gameId=${gameId} and ((duration != '00:00' and typeCode = 517) or typeCode != 517 )`;
|
|
48
56
|
return (await ctx.get(Endpoint.API_STATS, `en/shiftcharts?cayenneExp=${exprP}&exclude=${excludeP}`)).json();
|
|
49
|
-
}
|
|
57
|
+
}
|
|
50
58
|
/**
|
|
51
59
|
* Get the season-series record and contextual stats for a specific game,
|
|
52
60
|
* including team season stats and last games.
|
|
@@ -54,7 +62,9 @@ export const shiftChartData = async (ctx, { gameId, excludes = ['eventDetails']
|
|
|
54
62
|
* @param params.gameId Game id, e.g. 2023020280
|
|
55
63
|
* @example https://api-web.nhle.com/v1/gamecenter/2023020280/right-rail
|
|
56
64
|
*/
|
|
57
|
-
export
|
|
65
|
+
export async function seasonSeriesMatchup(ctx, { gameId }) {
|
|
66
|
+
return getWeb(ctx, `gamecenter/${gameId}/right-rail`);
|
|
67
|
+
}
|
|
58
68
|
/**
|
|
59
69
|
* Get the narrative game story for a specific game, including scoring
|
|
60
70
|
* summaries, three stars and team game stats.
|
|
@@ -62,7 +72,9 @@ export const seasonSeriesMatchup = async (ctx, { gameId }) => getWeb(ctx, `gamec
|
|
|
62
72
|
* @param params.gameId Game id, e.g. 2023020280
|
|
63
73
|
* @example https://api-web.nhle.com/v1/wsc/game-story/2023020280
|
|
64
74
|
*/
|
|
65
|
-
export
|
|
75
|
+
export async function gameStory(ctx, { gameId }) {
|
|
76
|
+
return getWeb(ctx, `wsc/game-story/${gameId}`);
|
|
77
|
+
}
|
|
66
78
|
export const gameCenterApi = {
|
|
67
79
|
boxscore,
|
|
68
80
|
playByPlay,
|