Skip to content

pitrho/motorsports-historic-data-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motorsports historic data API

Old car crash

An API for motorsports historical data, starting with NASCAR data. Data include lists of Drivers, Teams, and Crew Chiefs along with Team/Car Standings and Race lists. Most endpoints allow variable specificity from 'all', down to specified by season (year) and series (i.e. Sprint Cup).

All Series designations conform to the convention specified below under Series Designations.

API Configuration & Initial Setup

The following section describes the steps necessary to set up the API from scratch.

Dependencies

Begin by installing all required dependencies. We recommend using virtualenv to isolate this environment. It is also recommended that you use pip for package management. When you are in your environment, run:

pip install -r requirements.txt

Environment Variables

This requires some environment variables that are not tracked. Create a .env file that includes the following:

DATABASE_URL=postgresql://localhost/{{your_local_db_name}}
DEBUG=True

Initialize Database

Requires having Postgres (on a mac, we use Postgres.app) installed on your machine. First, create your empty database. From the shell:

createdb "your_local_db_name"

Then create the tables.

honcho run python ./app/manage.py database upgrade

(If there is no migrations folder, which is the case early on, while we're trying to finalize the models, before you run upgrade you'll want to run the following.)

honcho run python ./app/manage.py database migrate

Local Development

After you have initialized the application per API Configuration & Initial Setup, running the API locally is easy:

./bin/devserver.sh

Now you can hit the API by navigating to http://127.0.0.1:5000/api/{endpoint}

Production

You can deploy this to any production environment you choose. Below we describe how to deploy to Heroku.

Create the application

Follow steps at Heroku.com

Push to application

git push heroku master

Testing

We use nose for running tests. To run the full test suite make sure Postgres is running then use:

nosetests -v test

The testing database is postgresql://localhost/historic_api_test by default and can be overridden by specifying the TEST_DATABASE_URL variable in your environment.

Other Stuff

Series Designations

* w - NASCAR Sprint Cup Series
* b - NASCAR Nationwide Series
* c - NASCAR Camping World Truck Series
* p - K&N Pro Series West
* e - K&N Pro Series East
* o - Indy Cup
* a - ARCA
* f - Formula One
* ga - GrandAm

Pit Rho Conventions

  • We deploy most of our applications to Heroku and structure them as described in The Twelve Factor App.
  • We typically keep all configuration variables in files like .env and .env.production which we source using foreman or the Python clone honcho.

Packages commonly used at Pit Rho

License

See the LICENSE file.

Contributors

About

An API for motorsports historical data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published