# Hockey-API
## Purpose
The purpose of this package is to scrape data from ice hockey leagues, currently the NHL,
from available APIs and websites. The information that is scraped is both play by play and
shift data, with support for all parts of the seasons (preseason, regular season, all star and playoffs)
for seasons starting from 2010-2011.
## Getting started
A short introduction to the prerequisites and installation.
### Prerequisites
This package is built on Python, particularly Python3. To use this package, the Python version should be
at least 3.7.0.
### Installation
To install, simply open a terminal and run either of the following commands:
```python
pip install hockey_api
python -m pip install hockey_api
```
## Usage
To scrape data, three different functions are provided. Each function provides the same output structure,
with a tuple containing play by play data for all the game(s) as well as the shifts.
- To scrape a list of games, where the input should be a list of game ids:
```python
from hockey_api import scrape_list_of_games
# Scrape the first three games of the 2021-2022 NHL season.
pbp, shifts = scrape_list_of_games(game_id_list=[2021020001, 2021020002, 2021020003])
```
- To scrape a list of games between two dates:
```python
from hockey_api import scrape_date_range
# Scrape the all the games during the month of October in 2021.
pbp, shifts = scrape_date_range(start_date="2021-10-01", end_date="2021-10-31")
# Scrape games from a given date.
pbp, shifts = scrape_date_range(start_date="2021-10-31")
```
- To scrape a specific part of a season:
```python
from hockey_api import scrape_season
# Scrape all games from the 2021-2022 NHL regular season.
pbp, shifts = scrape_season(season=2021, season_type="R")
# Scrape all games from the 2021-2022 NHL playoffs.
pbp_playoffs, shifts_playoffs = scrape_season(season=2021, season_type="P")
```
### Saving data
To save data to a local file the following command should do:
```python
pbp.to_csv("desired/path/pbp.csv", index=False)
```
### Miscellaneous
An additional scraper is also available, called ```get_player_data()```, which
downloads metadata about all players in the NHL database. To use, simply run:
```python
from hockey_api import get_player_data
# Scrape player data
players = get_player_data()
```
## Contact
To get in contact with me send me an email at rasmus.safvenberg@gmail.com.
## Copyright
Copyright (C) 2022-2023 Rasmus Säfvenberg
This file is part of hockey_api
hockey_api is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Raw data
{
"_id": null,
"home_page": "https://github.com/Safvenberger/hockey-api",
"name": "hockey-api",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "scraping,hockey,sports analytics",
"author": "Rasmus S\u00e4fvenberg",
"author_email": "rasmus.safvenberg@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e0/b5/cff4109a4920df701e93e7c425d3181abcb153f744e9409c0e2507808642/hockey_api-0.1.1.tar.gz",
"platform": null,
"description": "# Hockey-API\n\n## Purpose\n\nThe purpose of this package is to scrape data from ice hockey leagues, currently the NHL, \nfrom available APIs and websites. The information that is scraped is both play by play and\nshift data, with support for all parts of the seasons (preseason, regular season, all star and playoffs)\nfor seasons starting from 2010-2011.\n\n## Getting started\n \nA short introduction to the prerequisites and installation.\n \n### Prerequisites\n\nThis package is built on Python, particularly Python3. To use this package, the Python version should be \nat least 3.7.0.\n\n### Installation\n\nTo install, simply open a terminal and run either of the following commands:\n\n```python\npip install hockey_api\npython -m pip install hockey_api\n```\n\n## Usage\n\nTo scrape data, three different functions are provided. Each function provides the same output structure, \nwith a tuple containing play by play data for all the game(s) as well as the shifts.\n\n- To scrape a list of games, where the input should be a list of game ids:\n```python\nfrom hockey_api import scrape_list_of_games\n\n# Scrape the first three games of the 2021-2022 NHL season.\npbp, shifts = scrape_list_of_games(game_id_list=[2021020001, 2021020002, 2021020003])\n```\n\n- To scrape a list of games between two dates:\n```python\nfrom hockey_api import scrape_date_range\n\n# Scrape the all the games during the month of October in 2021.\npbp, shifts = scrape_date_range(start_date=\"2021-10-01\", end_date=\"2021-10-31\")\n\n# Scrape games from a given date.\npbp, shifts = scrape_date_range(start_date=\"2021-10-31\")\n\n```\n\n- To scrape a specific part of a season:\n```python\nfrom hockey_api import scrape_season\n\n# Scrape all games from the 2021-2022 NHL regular season.\npbp, shifts = scrape_season(season=2021, season_type=\"R\")\n\n# Scrape all games from the 2021-2022 NHL playoffs.\npbp_playoffs, shifts_playoffs = scrape_season(season=2021, season_type=\"P\")\n```\n\n### Saving data\nTo save data to a local file the following command should do:\n```python\npbp.to_csv(\"desired/path/pbp.csv\", index=False)\n\n```\n\n### Miscellaneous\nAn additional scraper is also available, called ```get_player_data()```, which\ndownloads metadata about all players in the NHL database. To use, simply run:\n```python\nfrom hockey_api import get_player_data\n\n# Scrape player data\nplayers = get_player_data()\n```\n\n## Contact\nTo get in contact with me send me an email at rasmus.safvenberg@gmail.com.\n\n## Copyright\nCopyright (C) 2022-2023 Rasmus S\u00e4fvenberg\n\nThis file is part of hockey_api\n\nhockey_api is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <https://www.gnu.org/licenses/>.",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "Scraper for ice hockey data",
"version": "0.1.1",
"split_keywords": [
"scraping",
"hockey",
"sports analytics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b90aba0b20ba0564c18e352a71bd9b1dc92196635312bfc598b951970c2b22b9",
"md5": "682922cc8487c5ecc119c452c56837f0",
"sha256": "89fe9536f8b1c3dcb7391bdde20d37ee2fdfeb22744276e50f4559bf569948fb"
},
"downloads": -1,
"filename": "hockey_api-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "682922cc8487c5ecc119c452c56837f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 42999,
"upload_time": "2023-03-14T10:44:58",
"upload_time_iso_8601": "2023-03-14T10:44:58.608768Z",
"url": "https://files.pythonhosted.org/packages/b9/0a/ba0b20ba0564c18e352a71bd9b1dc92196635312bfc598b951970c2b22b9/hockey_api-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e0b5cff4109a4920df701e93e7c425d3181abcb153f744e9409c0e2507808642",
"md5": "e1bf2fc3177b853b2941d441c8d24c44",
"sha256": "21875726214df07af64a8857c8f0e8d6e8203da5d3b39ff9a0ee8751c261c805"
},
"downloads": -1,
"filename": "hockey_api-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "e1bf2fc3177b853b2941d441c8d24c44",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 38966,
"upload_time": "2023-03-14T10:45:00",
"upload_time_iso_8601": "2023-03-14T10:45:00.685103Z",
"url": "https://files.pythonhosted.org/packages/e0/b5/cff4109a4920df701e93e7c425d3181abcb153f744e9409c0e2507808642/hockey_api-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-14 10:45:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Safvenberger",
"github_project": "hockey-api",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "hockey-api"
}