A crowd-sourced stats provider.
S p o r t s D a t a b a s e . c o m
tools for the objective handicapper



This page gives examples of the SDQL API and assumes knowledge of the Sport Data Query Language.
For the discussion here you need to at least know that an SDQL query looks like this:


where `fields` is a comma delimited list of fields and correspond to a SQL SELECT clause and`conditions` is a conjunction delimited list of conditions that usurps both the SQL WHERE and SQL GROUP clauses.

Learning isn't by example - learning is example. - AE

To get the date and points scored for all Bears games in the 2011 season use the SDQL

date,points@team=Bears and season=2011

to form the url:


Note that in addition to the sdql, you need to specify output=json and your API key in the uri.

If you plan on generating fewer than 500 requests per day, use api_key=guest. For more than 500 requests a day, please e-mail api (a) sportsdatabase.com to get a key.

The returned JSON object will be:

{"headers": ['date', 'points'],
"groups": [ { "sdql": "team = Bears and season = 2011" ,
"columns" : [ [20110911,20110918,20110925,20111002,20111010,20111016,20111023,20111107,20111113,20111120,20111127,20111204,20111211,20111218,20111225,20120101],
[30,13,17,34,13,39,24,30,37,31,20,3,10,14,21,17] ]} ] }

This object contains a list of headers and a list of groups.
The headers are just the fields requested in the SDQL to the left of the `@`.
Each group contains the conditions of the SDQL used to form the group and a list of data columns corresponding to the headers.

Look at the source code of this page for a minimalist jquery example using this API.

To get the date, points and opponent's points for all Bears games in the 2011 season grouped by site use the SDQL

date,points,o:points@team=Bears and season=2011 and site

to form the url:


The returned JSON object will be:

{ "headers": ['date', 'points', 'o:points'],
"groups": [
{ "sdql": "team = Bears and season = 2011 and site = home" ,
"columns" : [ [20110911,20110925,20111002,20111016,20111113,20111120,20111204,20111218], [30,17,34,39,37,31,3,14], [12,27,29,10,13,20,10,38] ]},
{ "sdql": "team = Bears and season = 2011 and site = away" ,
"columns" : [ [20110918,20111010,20111023,20111107,20111127,20111211,20111225,20120101], [13,13,24,30,20,10,21,17], [30,24,18,24,25,13,35,13] ]} ] }

I hope that is enough to get started.

Consider joining the google discussion group for questions, updates, and to show off your app.

-by Joe Meyer
e-mail links:   Content@SportsDataBase.com    Support@SportsDataBase.com   
Content for this site is generated using the Sports Data Query Language (SDQL).