Types of requests
Tables in these docs support two base requests: get, and on most of them read. You'll see get used in most of the examples, but read works the same way on the tables that support it.
get
Returns the first matching row as a single object.
read
Returns every matching row, as an object keyed by id. Most filter arguments also accept an array of values, which are matched with an OR.
Example
GET
https://api.srating.io/v1/team/read?team_id=87019264-8549-11ed-bf01-5296e1552828&team_id=87c83148-8549-11ed-bf01-5296e1552828POST
fetch('https://api.srating.io/v1', {
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'X-API-KEY': 'YOUR_API_KEY',
},
'body': JSON.stringify({
'class': 'team',
'function': 'read',
'arguments': {
'team_id': [
'87019264-8549-11ed-bf01-5296e1552828',
'87c83148-8549-11ed-bf01-5296e1552828',
],
}
}),
}).then(response => {
return response.json();
}).then(json => {
console.log(json);
return json;
}).catch(error => {
console.log(error);
});Response
{
"87019264-8549-11ed-bf01-5296e1552828": {
"team_id": "87019264-8549-11ed-bf01-5296e1552828",
"char6": "PURDUE",
"code": "PUR",
"name": "Purdue Boilermakers",
"name_short": "Purdue",
"primary_color": "#010101",
"secondary_color": null,
"guid": null,
"deleted": 0
},
"87c83148-8549-11ed-bf01-5296e1552828": {
"team_id": "87c83148-8549-11ed-bf01-5296e1552828",
"char6": "RUTGER",
"code": "RUTG",
"name": "Rutgers Scarlet Knights",
"name_short": "Rutgers",
"primary_color": "#C8102E",
"secondary_color": null,
"guid": null,
"deleted": 0
}
}read is available on organization, division, game, team, player, coach, odds, boxscore, player_boxscore, elo, conference and cbb_transfer_player_season. On those tables it works the same way as get but returns everything that matches instead of just the first row. A read on any other table returns access denied, see Errors.
Custom requests
Some tables also have their own custom functions, on top of get and read, for the shape of data people actually ask for -- things like game/getGames, game/getOdds, team/getStats, and player/getGameLogs. These usually join in related rows (a game's odds and teams, a player's box score and the game it happened in) so you don't have to make several separate get/read calls and stitch the results together yourself. Each table's docs list the custom functions it supports.