summaryrefslogtreecommitdiff
path: root/build/lib/nba/fetch_data.py
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-15 22:37:06 -0500
committerChristian Cleberg <[email protected]>2026-04-15 22:37:06 -0500
commit4d40494f3e9aade0f5302678e4df67a7613c157b (patch)
treec12b55772f72c0221aacb8d4801bde309c46f8c6 /build/lib/nba/fetch_data.py
parentb542a36c072c353e9f3ba23c0fec99e55da8289a (diff)
downloadnba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.tar.gz
nba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.tar.bz2
nba-scores-4d40494f3e9aade0f5302678e4df67a7613c157b.zip
update README
Diffstat (limited to 'build/lib/nba/fetch_data.py')
-rw-r--r--build/lib/nba/fetch_data.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/build/lib/nba/fetch_data.py b/build/lib/nba/fetch_data.py
new file mode 100644
index 0000000..49503cc
--- /dev/null
+++ b/build/lib/nba/fetch_data.py
@@ -0,0 +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.
+
+ 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