nhle-api 0.5.3 → 0.5.4
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/CHANGELOG.md +38 -0
- package/README.md +161 -80
- package/lib/index.cjs +966 -252
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +378 -72
- package/lib/index.d.ts +378 -72
- package/lib/index.js +966 -253
- package/lib/index.js.map +1 -1
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,44 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.4] - 2026-02-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added game report tooling scripts for downloading and parsing summaries to support data collection workflows
|
|
13
|
+
- Added PlayerSearchResult response typing for Game Center player search
|
|
14
|
+
- Added test utilities for API response validation
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Reworked API response handling to use a `success` field instead of `status`, with simpler error handling
|
|
19
|
+
- Exported `nhlClient` as a named export and updated consumers
|
|
20
|
+
- Renamed the route helper to `resolvePath` and refactored Game Center/Edge Advanced Stats path builders
|
|
21
|
+
- Renamed Game Center and Edge Advanced Stats path modules from `_paths` to `paths` and cleaned up path object naming
|
|
22
|
+
- Restructured Edge Advanced Stats exports and converted module methods to standalone async functions
|
|
23
|
+
- Updated Edge Advanced Stats top10 schema validators to match the new path naming
|
|
24
|
+
- Overloaded game log and playoff series schedule helpers for flexible parameter handling
|
|
25
|
+
- Updated README usage examples and badges
|
|
26
|
+
- Simplified base URL handling in NHL client configuration
|
|
27
|
+
- Enhanced endpoint paths documentation for clarity and completeness across edge-adv module
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Corrected rankings response handling to align with `success` response payloads
|
|
32
|
+
- Removed a stray console log from `getSeason`
|
|
33
|
+
|
|
34
|
+
### Deprecated
|
|
35
|
+
|
|
36
|
+
- Marked the player search endpoint as deprecated; use the team roster endpoints for player information instead
|
|
37
|
+
|
|
38
|
+
### Technical
|
|
39
|
+
|
|
40
|
+
- Reorganized edge-stats tests and added edge-adv unit tests for goalies, skaters, summary, and teams
|
|
41
|
+
- Updated Game Center test utilities and imports for shared validation helpers
|
|
42
|
+
- Updated test coverage to handle error result objects
|
|
43
|
+
- Removed an unused Game Center index export
|
|
44
|
+
- Updated dependencies and devDependencies (including cheerio and node-html-parser)
|
|
45
|
+
|
|
8
46
|
## [0.5.3] - 2025-12-03
|
|
9
47
|
|
|
10
48
|
### Added
|
package/README.md
CHANGED
|
@@ -1,153 +1,234 @@
|
|
|
1
1
|
# NHLe API Library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/nhle-api)
|
|
4
|
+
[](https://www.npmjs.com/package/nhle-api)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A modern TypeScript wrapper around the public NHL GameCenter and EdgeStats APIs with simple, composable functions and strong TypeScript typing.
|
|
4
8
|
|
|
5
9
|
## Overview
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
The library exposes a small, functional surface over the NHL "Game Center" and related APIs and ships with rich response types for all Game Center endpoints.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
- Written in TypeScript and published as ESM/CJS
|
|
14
|
+
- Thin functional wrappers over official NHL API routes
|
|
15
|
+
- Fully-typed Game Center responses (game, team, player, draft, misc)
|
|
16
|
+
- Simple environment-based configuration for timeouts, language and logging
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
## Installation
|
|
12
19
|
|
|
13
20
|
```bash
|
|
14
21
|
npm install nhle-api
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
The package ships both ESM and CJS builds; use standard `import`/`require` according to your toolchain.
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
## Quick Start
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
The primary entrypoint is the Game Center API namespace `gc`:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { gc } from 'nhle-api';
|
|
23
32
|
|
|
24
33
|
// Get game landing page data
|
|
25
34
|
const gameInfo = await gc.game.landing(2023020001);
|
|
26
|
-
console.log(gameInfo);
|
|
27
35
|
|
|
28
36
|
// Get live play-by-play
|
|
29
37
|
const playByPlay = await gc.game.playByPlay(2023020001);
|
|
30
|
-
console.log(playByPlay);
|
|
31
38
|
|
|
32
39
|
// Get boxscore
|
|
33
40
|
const boxscore = await gc.game.boxscore(2023020001);
|
|
34
|
-
console.log(boxscore);
|
|
35
41
|
|
|
36
42
|
// Get today's scores
|
|
37
43
|
const scores = await gc.score(new Date());
|
|
38
|
-
console.log(scores);
|
|
39
44
|
|
|
40
45
|
// Get current scoreboard
|
|
41
46
|
const scoreboard = await gc.scoreboard();
|
|
42
|
-
console.log(scoreboard);
|
|
43
47
|
|
|
44
48
|
// Get team roster
|
|
45
|
-
const roster = await gc.team.roster(
|
|
46
|
-
console.log(roster);
|
|
49
|
+
const roster = await gc.team.roster('TOR');
|
|
47
50
|
|
|
48
|
-
// Get player
|
|
49
|
-
const player = await gc.player.landing(8478402);
|
|
50
|
-
console.log(player);
|
|
51
|
+
// Get player landing page (Connor McDavid)
|
|
52
|
+
const player = await gc.player.landing(8478402);
|
|
51
53
|
```
|
|
52
54
|
|
|
53
55
|
## Configuration
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
Basic behavior is configured via environment variables and the exported `envConfig` helper from `config/env`:
|
|
56
58
|
|
|
57
59
|
```bash
|
|
58
|
-
#
|
|
60
|
+
# Request timeout in milliseconds (default: 5000)
|
|
59
61
|
export NHLE_API_TIMEOUT=10000
|
|
60
62
|
|
|
61
|
-
#
|
|
63
|
+
# Language for responses ("en" or "fr", default: "en")
|
|
62
64
|
export NHLE_API_LANGUAGE=en
|
|
63
65
|
|
|
64
|
-
#
|
|
66
|
+
# Logging level: silent | error | warn | info | debug (default: "warn")
|
|
65
67
|
export NHLE_API_LOGLEVEL=debug
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
You can inspect the resolved configuration at runtime:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { envConfig, logEnvConfig } from 'nhle-api';
|
|
74
|
+
|
|
75
|
+
console.log(envConfig.timeout, envConfig.language, envConfig.logLevel);
|
|
76
|
+
logEnvConfig(); // logs only variables that are explicitly set
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
See `docs/ENVIRONMENT_CONFIG.md` for more details.
|
|
80
|
+
|
|
81
|
+
## Top-Level Exports
|
|
82
|
+
|
|
83
|
+
The package root `nhle-api` re-exports the main API namespaces, configuration utilities, constants, and public types:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
// Game Center API (fully typed)
|
|
87
|
+
import { gc } from 'nhle-api';
|
|
88
|
+
|
|
89
|
+
// Edge Advanced stats (in progress, API surface may change)
|
|
90
|
+
import { adv } from 'nhle-api';
|
|
91
|
+
|
|
92
|
+
// Environment configuration helpers
|
|
93
|
+
import { envConfig, logEnvConfig } from 'nhle-api';
|
|
94
|
+
|
|
95
|
+
// Shared type exports (Game Center response types, parameter types, etc.)
|
|
96
|
+
import type { GameLandingResponse } from 'nhle-api';
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Notes on Edge APIs
|
|
100
|
+
|
|
101
|
+
- `adv` (Edge Advanced) is available but still considered in development, but ready for preliminary use.
|
|
102
|
+
- The `stats` (Edge Stats) namespace is not exported at the moment and will be introduced in a future release once implementation is ready.
|
|
69
103
|
|
|
70
|
-
## API
|
|
104
|
+
## Game Center API (`gc`)
|
|
71
105
|
|
|
72
|
-
|
|
106
|
+
`gc` is the primary namespace for accessing live and historical NHL data.
|
|
73
107
|
|
|
74
|
-
|
|
108
|
+
### `gc.game` – Game Data
|
|
75
109
|
|
|
76
|
-
|
|
110
|
+
- `playByPlay(gameId)` – Full live play-by-play event stream
|
|
111
|
+
- `boxscore(gameId)` – Boxscore and team/player stats for a game
|
|
112
|
+
- `landing(gameId)` – Game landing page data (summary, lines, etc.)
|
|
113
|
+
- `reports(gameId)` – Game reports / right-rail data
|
|
114
|
+
- `schedule(date?)` – Schedule for a given date (defaults to today)
|
|
115
|
+
- `scheduleCalendar(date?)` – Calendar-style schedule for a date
|
|
116
|
+
- `playoffBracket(year?)` – Playoff bracket for a given year
|
|
117
|
+
- `playoffSeries(season?)` – Playoff series information for a season
|
|
118
|
+
- `playoffSeriesSchedule(season, seriesLetter)` – Schedule for a playoff series
|
|
119
|
+
- `whereToWatch()` – Regional broadcast / streaming info
|
|
120
|
+
- `networkTVSchedule(date?)` – National TV schedule
|
|
121
|
+
- `wsc.gameStory(gameId)` – Game story from the web service collection
|
|
122
|
+
- `wsc.playByPlay(gameId)` – Play-by-play from the web service collection
|
|
123
|
+
- `pptReplay.goal(gameId, eventId)` – Goal replay data for a specific event
|
|
124
|
+
- `pptReplay.event(date?)` – Replay events for a given date (does not appear to be functional at this time)
|
|
77
125
|
|
|
78
|
-
|
|
79
|
-
- `boxscore(gameId)` - Get boxscore for a game
|
|
80
|
-
- `landing(gameId)` - Get landing page data for a game
|
|
81
|
-
- `reports(gameId)` - Get game reports (right rail data)
|
|
82
|
-
- `schedule(date?)` - Get schedule for a specific date (defaults to today)
|
|
83
|
-
- `scheduleCalendar(date?)` - Get schedule calendar for a specific date
|
|
84
|
-
- `playoffBracket(year?)` - Get playoff bracket for a year
|
|
85
|
-
- `playoffSeries(season?)` - Get playoff series for a season
|
|
86
|
-
- `playoffSeriesSchedule(season, seriesLetter)` - Get schedule for a playoff series
|
|
87
|
-
- `whereToWatch()` - Get where to watch information
|
|
88
|
-
- `networkTVSchedule(date?)` - Get network TV schedule
|
|
89
|
-
- `wsc.gameStory(gameId)` - Get game story (web service)
|
|
90
|
-
- `wsc.playByPlay(gameId)` - Get play-by-play (web service)
|
|
91
|
-
- `pptReplay.goal(gameId, eventId)` - Get goal replay data
|
|
92
|
-
- `pptReplay.event(date?)` - Get replay events for a date
|
|
126
|
+
### `gc.score` – Scores & Scoreboards
|
|
93
127
|
|
|
94
|
-
|
|
128
|
+
- `score(date?)` – Scores for a given date (defaults to today)
|
|
129
|
+
- `scoreboard()` – Current live scoreboard
|
|
95
130
|
|
|
96
|
-
|
|
97
|
-
- `scoreboard()` - Get current scoreboard
|
|
131
|
+
### `gc.team` – Team Data
|
|
98
132
|
|
|
99
|
-
|
|
133
|
+
- `roster(teamCode, season?)` – Team roster for a given season
|
|
134
|
+
- `rosterSeasons(teamCode)` – Available roster seasons for a team
|
|
135
|
+
- `prospects(teamCode)` – Team prospects
|
|
136
|
+
- `clubStats(teamCode, season?)` – Club stats for a team/season
|
|
137
|
+
- `clubStatsSeason(teamCode)` – Season-level club stats
|
|
138
|
+
- `standings(date?)` – Standings for a given date
|
|
139
|
+
- `standingsSeason()` – Season standings
|
|
140
|
+
- `schedule.now(teamCode)` – Current schedule segment for a team
|
|
141
|
+
- `schedule.month(teamCode, month)` – Team schedule for a given month
|
|
142
|
+
- `schedule.season(teamCode, season)` – Full season schedule for a team
|
|
100
143
|
|
|
101
|
-
|
|
102
|
-
- `rosterSeasons(teamCode)` - Get available roster seasons
|
|
103
|
-
- `prospects(teamCode)` - Get team prospects
|
|
104
|
-
- `clubStats(teamCode, season?)` - Get club stats
|
|
105
|
-
- `clubStatsSeason(teamCode)` - Get club stats season
|
|
106
|
-
- `standings(date?)` - Get standings for a date
|
|
107
|
-
- `standingsSeason()` - Get standings by season
|
|
108
|
-
- `schedule.now(teamCode)` - Get team's current schedule
|
|
109
|
-
- `schedule.month(teamCode, month)` - Get team's schedule for a month
|
|
110
|
-
- `schedule.season(teamCode, season)` - Get team's schedule for a season
|
|
144
|
+
### `gc.player` – Player Data
|
|
111
145
|
|
|
112
|
-
|
|
146
|
+
- `landing(playerId)` – Player landing page data
|
|
147
|
+
- `gameLog(playerId, season?, gameType?)` – Game log for a player
|
|
148
|
+
- `spotlight()` – Featured players (spotlight carousel)
|
|
149
|
+
- `search(query)` – Player search
|
|
150
|
+
- `statsLeaders.season(season?, gameType?, category?, limit?)` – Season stat leaders
|
|
151
|
+
- `statsLeaders.current(gameType?, category?, limit?)` – Current stat leaders
|
|
113
152
|
|
|
114
|
-
|
|
115
|
-
- `gameLog(playerId, season?, gameType?)` - Get player game log
|
|
116
|
-
- `spotlight()` - Get featured players
|
|
117
|
-
- `search(query)` - Search for players
|
|
118
|
-
- `statsLeaders.season(season?, gameType?, category?, limit?)` - Get season stats leaders
|
|
119
|
-
- `statsLeaders.current(gameType?, category?, limit?)` - Get current stats leaders
|
|
153
|
+
### `gc.draft` – Draft Data
|
|
120
154
|
|
|
121
|
-
|
|
155
|
+
- `picks(year?)` – Draft picks for a given year
|
|
156
|
+
- `tracker()` – Draft tracker
|
|
157
|
+
- `rankings(year?)` – Draft rankings (all, NA/International, skaters/goalies)
|
|
122
158
|
|
|
123
|
-
|
|
124
|
-
- `tracker()` - Get draft tracker
|
|
125
|
-
- `rankings(year?)` - Get draft rankings
|
|
159
|
+
### `gc.misc` – Miscellaneous
|
|
126
160
|
|
|
127
|
-
|
|
161
|
+
- `seasons()` – All NHL seasons
|
|
162
|
+
- `meta.game(gameId)` – Game metadata
|
|
163
|
+
- `meta.gameVideo(gameId)` – Game video metadata
|
|
164
|
+
- `postalLookup(postalCode)` – Postal/ZIP lookup (location info)
|
|
165
|
+
- `location()` – Location info for current context
|
|
166
|
+
- `partnerGame(country, date?)` – Partner game information
|
|
128
167
|
|
|
129
|
-
|
|
130
|
-
- `meta.game(gameId)` - Get game metadata
|
|
131
|
-
- `meta.gameVideo(gameId)` - Get game video metadata
|
|
132
|
-
- `postalLookup(postalCode)` - Lookup location by postal code
|
|
133
|
-
- `location()` - Get current location info
|
|
134
|
-
- `partnerGame(country, date?)` - Get partner game information
|
|
168
|
+
## Types
|
|
135
169
|
|
|
136
|
-
|
|
170
|
+
The library exports strongly-typed response shapes and parameter types for all Game Center endpoints from the `types` bundle:
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
- Response types for `gc.game.*`, `gc.team.*`, `gc.player.*`, `gc.draft.*`, `gc.misc.*`
|
|
173
|
+
- Common enums and helper types (position codes, team codes, schedule state, etc.)
|
|
139
174
|
|
|
140
|
-
### Edge Advanced API (`adv`) - _In Development_
|
|
141
175
|
|
|
142
|
-
|
|
176
|
+
|
|
177
|
+
### Error Handling and `NHLError`
|
|
178
|
+
|
|
179
|
+
Under the hood, low-level HTTP requests use a shared `NHLClient` and `ErrorHandler` which normalize HTTP/network failures into a single `NHLError` shape.
|
|
180
|
+
|
|
181
|
+
- All non-2xx responses and network/timeout failures are converted to an `NHLError` instance.
|
|
182
|
+
- Errors are categorized (client/server/network) with optional context (endpoint, method, status code).
|
|
183
|
+
- High-level helpers expose these via the `APIResponse<T>` union so you can safely branch on `status` without catching exceptions.
|
|
184
|
+
|
|
185
|
+
Typical usage pattern:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { gc } from 'nhle-api';
|
|
189
|
+
import type { APIResponse, GamecenterLanding } from 'nhle-api';
|
|
190
|
+
|
|
191
|
+
const result: APIResponse<GamecenterLanding> = await gc.game.landing(2023020001);
|
|
192
|
+
|
|
193
|
+
if (result.success) {
|
|
194
|
+
console.log(result.data);
|
|
195
|
+
} else {
|
|
196
|
+
// NHLError instance with rich metadata
|
|
197
|
+
console.error(result.error.message);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Roadmap / Status
|
|
202
|
+
|
|
203
|
+
- ✅ Game Center endpoints fully wired with response types
|
|
204
|
+
- ✅ Environment configuration utilities (`envConfig`, `logEnvConfig`)
|
|
205
|
+
- ✅ Error handling via `NHLError` and structured error responses internally
|
|
206
|
+
- 🚧 Edge Advanced (`adv`) API surface and types are in development
|
|
207
|
+
- ⏳ Edge Stats (`stats`) API will be added in a future minor release
|
|
208
|
+
|
|
209
|
+
For a detailed list of changes and recent work on response types and endpoint coverage, see `CHANGELOG.md`.
|
|
143
210
|
|
|
144
211
|
## Docs
|
|
145
212
|
|
|
146
|
-
- [Environment Configuration](docs/ENVIRONMENT_CONFIG.md) -
|
|
147
|
-
- [Query Builder Guide](docs/QUERY_BUILDER_GUIDE.md) -
|
|
213
|
+
- [Environment Configuration](docs/ENVIRONMENT_CONFIG.md) - Environment configuration and default values
|
|
214
|
+
- [Query Builder Guide](docs/QUERY_BUILDER_GUIDE.md) - Cayenne query builder for stats APIs
|
|
215
|
+
|
|
216
|
+
## Contributing
|
|
217
|
+
|
|
218
|
+
This project is still evolving and feedback is very welcome.
|
|
219
|
+
|
|
220
|
+
- **Bug reports / issues:** If an endpoint returns unexpected data, response parsing fails, or types don’t match the real API, please open a GitHub issue with the endpoint, parameters, and (sanitized) sample payloads if possible.
|
|
221
|
+
- **Type improvements:** PRs or issues that improve response coverage, fix missing/incorrect fields, or refine enums and unions are particularly helpful.
|
|
222
|
+
- **JSDoc / docs:** Additions or corrections to JSDoc on public types and functions, or clarifications to the guides in `docs/`, are also very much appreciated.
|
|
223
|
+
|
|
224
|
+
Before filing an issue, check the `CHANGELOG.md` for recent changes and breaking notes, and include the library version you’re using.
|
|
148
225
|
|
|
149
226
|
## Support
|
|
150
227
|
|
|
151
228
|
If you find this library helpful, consider supporting its development:
|
|
152
229
|
|
|
153
230
|
[](https://ko-fi.com/R6R01DV0JD)
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|