diff options
Diffstat (limited to 'nba/fetch_data.py')
-rw-r--r-- | nba/fetch_data.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/nba/fetch_data.py b/nba/fetch_data.py index 71cac33..49503cc 100644 --- a/nba/fetch_data.py +++ b/nba/fetch_data.py @@ -1,28 +1,30 @@ """ Fetches data for use in other modules. """ + import json from nba_api.live.nba.endpoints import scoreboard from nba_api.stats.endpoints import leaguestandings + def fetch_data() -> tuple: - """ - Fetches live NBA scoreboard data and standings from the NBA API. + """ + Fetches live NBA scoreboard data and standings from the NBA API. - Returns: - games (dict): JSON parsed games data. - standings (dict): JSON parsed team standings data. - """ - # Get today's scoreboard data - games_endpoint = scoreboard.ScoreBoard() - games_json = games_endpoint.get_json() + Returns: + games (dict): JSON parsed games data. + standings (dict): JSON parsed team standings data. + """ + # Get today's scoreboard data + games_endpoint = scoreboard.ScoreBoard() + games_json = games_endpoint.get_json() - # Get league standings - standings_endpoint = leaguestandings.LeagueStandings() - standings_json = standings_endpoint.get_json() + # Get league standings + standings_endpoint = leaguestandings.LeagueStandings() + standings_json = standings_endpoint.get_json() - # Parse the JSON strings into Python dictionaries - games = json.loads(games_json) - standings = json.loads(standings_json) + # Parse the JSON strings into Python dictionaries + games = json.loads(games_json) + standings = json.loads(standings_json) - return games, standings + return games, standings |