|
SportsDatabase.com
peer-to-peer sports data with the SDQL API |
Data APIThe SDQL Data API has two parts: POST requests are used to update a sports database and GET requests are used for SDQL queries into a sports database.POST requests are made to https://s3.SportsDatabase.com/api and require headers of: user, token, league, action . Allowed values for action are: update, replace, and remove. The POST payload is a specialized JSON dictionary describing a sports game. The main specialization consists of using the parameter prefx 't:' for team stats and 'o:' for opponent stats. Stats that are not team specific, like `date`, do not need a parameter prefix. Another specialization is that a list of dictionaries is used to specify player-level data. To post a JSON dictionary for the game on March 10, 2020 when the Bulls hosted the Cavaliers and won 108 to 103, use the JSON request:
header: { "token": "YOUR_TOKEN",
"user": "YOUR_USERNAME",
"league": "NBA",
"action": "replace" }
data: { "date": 20200310,
"t:team": "Bulls",
"o:team": "Cavaliers",
"t:site": "home",
"o:site": "away",
"t:points": 108,
"o:points": 103,
"t:Players": [{"name":"Coby White","points":20,"minutes":38.0},
{"name":"Denzel Valentine","points":15,"minutes":22.7},
...
],
"o:Players": [{"name":"Collin Sexton","points":26,"minutes":36.5},
{"name":"Andre Drummond","points":21,"minutes":34.5},
...
]
}
Note that the ... means to make a dictionary for every player and that player level dictionaries must contain the key "name" In order to locate the game in the database, all sports have required data keys of: date, t:team, o:team. For baseball the key double header is also required. GET requests are made to https://s3.sportsdatabase.com/LEAGUE/query When making a GET request the following headers are required: user, token. The GET request is made with a JSON dictionary describing a query. The only required dictionary key is: sdql. To get the win-loss record of the Chicago Blackhawks in 2019, use the JSON request:
header: { "token": "YOUR_TOKEN",
"user": "YOUR_USERNAME"}
data: {"sdql": "S(W),S(L)@team='Chicago Blackhawks' and season=2019"}
|
| support@SportsDatabase.com          eyeball communications llc |