I am leaving this repository up for demonstration purposes. The API service has shut down. RIP.
A Python module made to interface with The 5th Row sports data API
I started this project to practice writing Pythonic programs (feel free to let me know how I did with that).
The program is pretty straight forward and easy to use.
To begin making requests to the API, create an object of the FifthRow
class like so
from fifth_row import FifthRow
f = FifthRow()
The class defaults to the sandboxed API, so passing no parameters to the constructor is fine for experimenting.
Now that f
has been instantiated, we can start making requests using f.get()
matches = f.get(sport='nba', team='ny', status='upcoming')
f.get()
returns a generator filled with Matchup
objects. These objects hold all the data for every individual match that was returned by our request.
In the event that the API can't find any matchups that meet your request, the method will return a generator containing one NoMatchup
object. The NoMatchup
object has one attribute, message
, that contains the response returned from the API.
The API response objects are similar to this (taken straight from their docs)
{
home: { team: ..., code: ... },
away: { team: ..., code: ... },
begins: { date: ..., time: ..., iso: ... },
sport: ...,
status: "upcoming"
}
The Matchup
objects extract this data and store it in properly named attributes. For instance, the matches home team value can be found in the Matchup
object at its attribute home_team
. For the away team the value is stored in, you guessed it, the away_team
attribute.
Since the get
method returns a generator, the easiest way to extract each matches information is by iterating through them
for match in FifthRow.get('nba'):
print match.status
print match.home
print match.away
if match.status is 'upcoming':
print match.begin_date
And there you have it.