Types of requests
Every table in these docs supports two base requests: get and read. You'll see get used in most of the examples, but read works the same way on the same tables.
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": "Purdue",
"name": "Purdue Boilermakers",
"alt_name": "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": "Rutgers",
"name": "Rutgers Scarlet Knights",
"alt_name": "Rutgers",
"primary_color": "#C8102E",
"secondary_color": null,
"guid": null,
"deleted": 0
}
}read is available on nearly every table (game, team, player, coach, odds, boxscore, player_boxscore, elo, conference, cbb_transfer_player_season, and more) — anywhere you see a get request in these docs, read works the same way but returns everything that matches instead of just the first row.
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.