blob: 71cac3344d7cfdb0481d8401095a68836c11f958 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
"""
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.
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()
# Parse the JSON strings into Python dictionaries
games = json.loads(games_json)
standings = json.loads(standings_json)
return games, standings
|