Mar 4, 2009
Simplest API Ever?
Last week I announced on Twitter that I had written a really simple python script to rip AFL scores from the AFL’s Game Day Live page. It had a pretty decent response so I’ve turned it into a quick and dirty web server for anyone to use.

Using web.py meant that the web service took all of about 20 minutes to actually code up, the biggest problem was getting Lighttpd virtual hosts to play nice on a server with multiple domains hosted.
For anyone interested the complete code (all 2Kb of it) is available here: http://sesh.gubbyprojects.com/labs/score/
And now to the fun part - explaining the single API call that this makes available.
I’ve created a sub domain specifically for this API, and it has just two parameters:
http://scores.gubbyprojects.com/{sport}/{team(s)}/
You’re going to need to fill in those two parameters with valid values; for the sport you need to put “afl”, and for teams you need to put the name of the AFL teams you want scores for - seperated by commas.
Here’s an example for this Friday’s game:
http://scores.gubbyprojects.com/afl/essendon,collingwood/
Check out what it returns - it’s so self explanitory that it’s hardly worth exaplaining:
Return Value:
ESSENDON,{Q1},{Q2},{Q3},{Q4},{total}
COLLINGWOOD,{Q1},{Q2},{Q3},{Q4},{total}
One little gotcha is that you can’t put spaces in the domain. You just need to make sure that you’re using a unique piece of text from the team name that appears on the Game Day Live page. For “West Coast” you can use “Coast” and for “Western Bulldogs” you can use either “Western” or “Bulldogs”.
That’s about it for now, I’m going to be expaning this a fair bit in the next going of weeks - but this call won’t change at all.
Plans for the immediate future:
- Get a list of games for the week
- Get more details about a specific game (time remaining, goal scorers, etc.)