A Python application that utilizes National Basketball Association (NBA) focused APIs from sportradar.us to retrieve all team rosters and available free agents. This application allows a user to easily retrieve key information on team players and search for available free agents with an experience requirement if desired. Furthermore, we have added CSV functionality to seamlessly allow a user to export the free agents data.
- Alex Fleshner
- Larry Doroger
- Meghana Reddy
- Anaconda 3.7+
- Python 3.7+
- Pip
Fork this remote repository under your own control, then "clone" or download your remote copy onto your local computer.
Then navigate there from the command line (subsequent commands assume you are running them from the local repository's root directory):
cd ~/Desktop/NBAUse Anaconda to create and activate a new virtual environment, perhaps called "nba-env":
conda create -n nba-env python=3.8
conda activate nba-envAfter activating the virtual environment, install package dependencies (see the "requirements.txt" file):
pip install -r requirements.txtNOTE: if this command throws an error like "Could not open requirements file: [Errno 2] No such file or directory", make sure you are running it from the repository's root directory, where the requirements.txt file exists (see the initial
cdstep above).
Signup for Sportradar.us API:
- Obtain a Sportradar.us API Key to be entered in the .env file as (
api_key).
Create a new file called ".env" in the root directory of this repo, then copy the contents below into it, adapting the values to match the api_key from Sportradar.us.
# the .env file
api_key="abc123"NOTE: the ".env" file is usually the place for passing configuration options and secret credentials, so as a best practice we don't upload this file to version control (which is accomplished via a corresponding entry in the ".gitignore" file). This means we need to instruct each person who uses our code needs to create their own local ".env" file.
Run the Python script:
python app/nba_search.pyNOTE: if you see an error like "ModuleNotFoundError: No module named '...'", it's because the given package isn't installed, so run the
pipcommand above to ensure that package has been installed into the virtual environment.
Running tests:
pytestThank you to Professor Rossetti for providing great instruction and assistance during this course! As well as a reference README file and CSV module configuration instructions within GitHub.