Skip to content

Commit 0f48241

Browse files
Added NHL API (#149)
- Added config - Added test.py - Added 3 examples on README.md
1 parent ccd9bac commit 0f48241

File tree

6 files changed

+315
-0
lines changed

6 files changed

+315
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,68 @@ tag_count
33983398

33993399
### Sports
34003400

3401+
#### [NHL](./api-connectors/nhl) -- Collect National Hockey League Data
3402+
3403+
<details>
3404+
<summary>How long was the 2000 - 2001 season?</summary>
3405+
3406+
```python
3407+
from dataprep.connector import connect
3408+
import pandas as pd
3409+
3410+
conn = Connector(config_path="./config")
3411+
df = await conn.query("seasons")
3412+
3413+
#string to datetime
3414+
df["regularSeasonStartDate"] = pd.to_datetime(df["regularSeasonStartDate"])
3415+
df["regularSeasonEndDate"] = pd.to_datetime(df["regularSeasonEndDate"])
3416+
df['season_length'] = df["regularSeasonEndDate"] - df["regularSeasonStartDate"]
3417+
3418+
#selecting 2000/2001 season
3419+
df.loc[df["seasonId"] == "20002001"][["seasonId", "season_length"]]
3420+
```
3421+
| seasonId | season_length |
3422+
| --------- | --------------- |
3423+
| 20002001 | 186 days |
3424+
3425+
</details>
3426+
3427+
<details>
3428+
<summary>What is the venue of the Pittsburgh Penguins called?</summary>
3429+
3430+
```python
3431+
from dataprep.connector import connect
3432+
3433+
conn = Connector(config_path="./config")
3434+
df = await conn.query("teams", expand="team.roster", season="20202021")
3435+
3436+
df.loc[df["name"]=="Pittsburgh Penguins"][["name","venue_name"]]
3437+
```
3438+
| name | venue_name |
3439+
| -------------------- | ----------------- |
3440+
| Pittsburgh Penguins | PPG Paints Arena |
3441+
3442+
</details>
3443+
3444+
<details>
3445+
<summary>What are the names of all the Team awards in the NHL?</summary>
3446+
3447+
```python
3448+
from dataprep.connector import connect
3449+
3450+
conn = Connector(config_path="./config")
3451+
df = await conn.query("awards")
3452+
3453+
df.loc[df["recipientType"] == "Team"][["name"]]
3454+
```
3455+
| name |
3456+
| ------------------------- |
3457+
| Stanley Cup |
3458+
| Clarence S. Campbell Bowl |
3459+
| Presidents’ Trophy |
3460+
| Prince of Wales Trophy |
3461+
3462+
</details>
34013463

34023464
#### [TheSportsDB](./api-connectors/thesportsdb) -- Collect Team and League Data
34033465

api-connectors/nhl/_meta.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tables":[
3+
"teams",
4+
"awards",
5+
"seasons"
6+
]
7+
}

api-connectors/nhl/awards.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "http://statsapi.web.nhl.com/api/v1/awards",
5+
"method": "GET",
6+
"params": {}
7+
},
8+
"response": {
9+
"ctype": "application/json",
10+
"tablePath": "$.awards[*]",
11+
"schema": {
12+
"name": {
13+
"target": "$.name",
14+
"type": "string"
15+
},
16+
"shortName": {
17+
"target": "$.shortName",
18+
"type": "string"
19+
},
20+
"recipientType": {
21+
"target": "$.recipientType",
22+
"type": "string"
23+
},
24+
"description": {
25+
"target": "$.description",
26+
"type": "string"
27+
},
28+
"history": {
29+
"target": "$.history",
30+
"type": "string"
31+
},
32+
"imageUrl": {
33+
"target": "$.imageUrl",
34+
"type": "string"
35+
},
36+
"homePageUrl": {
37+
"target": "$.homePageUrl",
38+
"type": "string"
39+
},
40+
"link": {
41+
"target": "$.link",
42+
"type": "string"
43+
}
44+
},
45+
"orient": "records"
46+
}
47+
}

api-connectors/nhl/seasons.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "http://statsapi.web.nhl.com/api/v1/seasons",
5+
"method": "GET",
6+
"params": {}
7+
},
8+
"response": {
9+
"ctype": "application/json",
10+
"tablePath": "$.seasons.[*]",
11+
"schema": {
12+
"seasonId": {
13+
"target": "$.seasonId",
14+
"type": "string"
15+
},
16+
"regularSeasonStartDate": {
17+
"target": "$.regularSeasonStartDate",
18+
"type": "string"
19+
},
20+
"regularSeasonEndDate": {
21+
"target": "$.regularSeasonEndDate",
22+
"type": "string"
23+
},
24+
"numberOfGames": {
25+
"target": "$.numberOfGames",
26+
"type": "int"
27+
},
28+
"tiesInUse": {
29+
"target": "$.tiesInUse",
30+
"type": "boolean"
31+
},
32+
"olympicsParticipation": {
33+
"target": "$.olympicsParticipation",
34+
"type": "boolean"
35+
},
36+
"conferencesInUse": {
37+
"target": "$.conferencesInUse",
38+
"type": "boolean"
39+
},
40+
"divisionsInUse": {
41+
"target": "$.divisionsInUse",
42+
"type": "boolean"
43+
},
44+
"wildCardInUse": {
45+
"target": "$.wildCardInUse",
46+
"type": "boolean"
47+
}
48+
},
49+
"orient": "records"
50+
}
51+
}

api-connectors/nhl/teams.json

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"version": 1,
3+
"request": {
4+
"url": "http://statsapi.web.nhl.com/api/v1/teams",
5+
"method": "GET",
6+
"params": {
7+
"teamId": false,
8+
"expand": false,
9+
"season": false
10+
}
11+
},
12+
"response": {
13+
"ctype": "application/json",
14+
"tablePath": "$.teams[*]",
15+
"schema": {
16+
"id": {
17+
"target": "$.id",
18+
"type": "int"
19+
},
20+
"name": {
21+
"target": "$.name",
22+
"type": "string"
23+
},
24+
"link": {
25+
"target": "$.link",
26+
"type": "string"
27+
},
28+
"venue_name": {
29+
"target": "$.venue.name",
30+
"type": "string"
31+
},
32+
"venue_link": {
33+
"target": "$.venue.link",
34+
"type": "string"
35+
},
36+
"venue_city": {
37+
"target": "$.venue.city",
38+
"type": "string"
39+
},
40+
"venue_timeZone_id": {
41+
"target": "$.venue.timeZone.id",
42+
"type": "string"
43+
},
44+
"venue_timeZone_offset": {
45+
"target": "$.venue.timeZone.offset",
46+
"type": "string"
47+
},
48+
"venue_timeZone_tz": {
49+
"target": "$.venue.timeZone.tz",
50+
"type": "string"
51+
},
52+
"abbreviation": {
53+
"target": "$.abbreviation",
54+
"type": "string"
55+
},
56+
"teamName": {
57+
"target": "$.teamName",
58+
"type": "string"
59+
},
60+
"locationName": {
61+
"target": "$.locationName",
62+
"type": "string"
63+
},
64+
"firstYearOfPlay": {
65+
"target": "$.firstYearOfPlay",
66+
"type": "string"
67+
},
68+
"division_id": {
69+
"target": "$.division.id",
70+
"type": "string"
71+
},
72+
"division_name": {
73+
"target": "$.division.name",
74+
"type": "string"
75+
},
76+
"division_link": {
77+
"target": "$.division.name",
78+
"type": "string"
79+
},
80+
"division_abbreviation": {
81+
"target": "$.division.name",
82+
"type": "string"
83+
},
84+
"conference_id": {
85+
"target": "$.conference.id",
86+
"type": "string"
87+
},
88+
"conference_name": {
89+
"target": "$.conference.name",
90+
"type": "string"
91+
},
92+
"conference_link": {
93+
"target": "$.conference.link",
94+
"type": "string"
95+
},
96+
"franchise_id": {
97+
"target": "$.franchise.franchiseId",
98+
"type": "string"
99+
},
100+
"franchise_teamName": {
101+
"target": "$.franchise.teamName",
102+
"type": "string"
103+
},
104+
"franchise_link": {
105+
"target": "$.franchise.link",
106+
"type": "string"
107+
},
108+
"shortName": {
109+
"target": "$.shortName",
110+
"type": "string"
111+
},
112+
"officialSiteUrl": {
113+
"target": "$.officialSiteUrl",
114+
"type": "string"
115+
},
116+
"franchiseId": {
117+
"target": "$.franchiseId",
118+
"type": "int"
119+
},
120+
"teamStats": {
121+
"target": "$.teamStats",
122+
"type": "list"
123+
},
124+
"nextGameSchedule": {
125+
"target": "$.nextGameSchedule",
126+
"type": "object"
127+
},
128+
"previousGameSchedule": {
129+
"target": "$.previousGameSchedule",
130+
"type": "object"
131+
},
132+
"roster": {
133+
"target": "$.roster",
134+
"type": "object"
135+
},
136+
"active": {
137+
"target": "$.active",
138+
"type": "boolean"
139+
}
140+
},
141+
"orient": "records"
142+
}
143+
}

api-connectors/nhl/tests/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from dataprep.connector import Connector
2+
3+
4+
def test_sanity():
5+
Connector("./nhl")

0 commit comments

Comments
 (0)