-
Notifications
You must be signed in to change notification settings - Fork 38
API Endpoints
All API endpoints expect a HTTP header in the form:
Authorization: Token abc123
where abc123
is the secret token of an API key in the database.
GET
/api/find_pairing/?player={username}
/api/find_pairing/?white={username}&black={username}
/api/find_pairing/?league={league_tag}&player={username}
/api/find_pairing/?league={league_tag}&season={season_tag}&player={username}
/api/find_pairing/?league={league_tag}&season={season_tag}&white={username}&black={username}
/api/find_pairing/?league={league_tag}&season={season_tag}&scheduled=false
Finds the active pairing(s) matching the given parameters. If a pairing is not found with the specified colors it will look for a pairing with opposite colors.
Result format:
{
"pairings": [{
"league": "team4545",
"season": "4",
"round": 5,
"white_team": "The Little Forkers",
"white_team_number": 10
"black_team": "Knife f5",
"black_team_number": 5,
"white": "brianmcdonald",
"white_rating": 2076,
"black": "cyanfish",
"black_rating": 2159,
"game_link": "http://en.lichess.org/FVDwoKeI",
"result": "0-1",
"datetime": "2016-07-21T22:00:00Z"
}, {
"league": "lonewolf",
"season": "4",
"round": 5,
"white": "brianmcdonald",
"white_rating": 2076,
"black": "cyanfish",
"black_rating": 2159,
"game_link": "http://en.lichess.org/FVDwoKeI",
"result": "0-1",
"datetime": "2016-07-21T22:00:00Z"
}]
}
Error format:
{
"pairings": null,
"error": "no_matching_rounds"
}
Possible errors: no_matching_rounds
POST
/api/update_pairing/
Updates the active pairing(s) corresponding to the given player(s) and league/season.
Form data parameters:
# Query parameters
league={league_tag}
season={season_tag}
white={username}
black={username}
# Update parameters
game_link={url}
result={result_str}
datetime={datetime_str}
All parameters are optional. Unrecognized parameters are ignored.
Result format:
{
"updated": 1
}
Error format:
{
"updated": 0,
"error": "not_found"
}
Possible errors: no_matching_rounds
, not_found
, ambiguous
GET
/api/get_roster/?league={league_tag}
/api/get_roster/?league={league_tag}&season={season_tag}
Gets the rosters for the specified season or the current season of the specified league. Alternates are sorted by their priority (highest first).
Result format:
{
"league": "team4545",
"season": "4",
"players": [{
"username": "cyanfish",
"rating": 2159
}, ...],
"teams": [{
"name": "Knights who say 'Nf3'",
"number": 1,
"slack_channel": "G4MFRBZ1D",
"players": [{
"username": "Atrophied",
"is_captain": false,
"board_number": 1
}, ...]
}, ...]
"alternates": [{
"board_number": 1,
"usernames": ["Kobol", ...]
}, ...]
Error format:
{
"season_id": null,
"players": null,
"teams": null,
"error": "no_matching_rounds"
}
Possible errors: no_matching_rounds
POST
/api/assign_alternate/
Assigns an alternate for the given round. Only designated alternates for the given board (or team members playing up) are allowed as alternates.
Original players can be replaced using the same endpoint. To reassign, apply the original player in the {player} argument of the endpoint.
After assignment, future calls to get_roster endpoint will continue to return the original player.
Form data parameters:
league={league_tag}
season={season_tag}
round={round_num}
team={team_num}
board={board_num}
player={player_name}
All parameters except league
/season
are mandatory.
Result format:
{
"updated": 1
}
Error format:
{
"updated": 0,
"error": "not_an_alternate"
}
Possible errors: no_matching_rounds
, player_not_found
, round_over
, not_an_alternate
POST
/api/set_availability/
Sets availability for the given player and round.
Form data parameters:
league={league_tag}
season={season_tag}
round={round_num}
player={player_name}
available={true|false}
All parameters except league
/season
are mandatory.
Result format:
{
"updated": 1
}
Error format:
{
"updated": 0,
"error": "round_over"
}
Possible errors: no_matching_rounds
, player_not_found
, round_over
GET
/api/get_league_moderators/?league={league_tag}
Gets a list of moderators for the specified league.
Result format:
{
"moderators": ["cyanfish", "endrawes0", "jptriton", "lakinwecker"]
}
GET
/api/league_document/?league={league_tag}&type={document_type}&strip_html={true|false}
Gets the league document of the given type.
Result format:
{
"name": "{document_name}",
"content": "{document_content}"
}
Error format:
{
"name": null,
"content": null,
"error": "not_found"
}
Possible errors: not_found
GET
/api/get_private_url/?league={league_tag}&page={page}&user={username}
/api/get_private_url/?league={league_tag}&season={season_tag}&page={page}&user={username}
Gets a private url for the given user and page. The caller asserts that the returned url will be provided only to the specified user.
Possible values for page
:
nominate
notifications
Result format:
{
"url": "https://www.lichess4545.com/team4545/nominate/HJBSwEJQ7k8Ir/"
"expires": "2016-07-21T22:05:52Z"
}
Error format:
{
"url": null,
"expires": null,
"error": "invalid_page"
}
Possible errors: invalid_page
POST
/api/player_joined_slack/?name={name}
Tells the website that the player with a given name joined slack. {name} is a required field.
Result format:
{
"updated": 1
}
Error format:
{
"updated": 0,
"error": "not_found"
}
Possible errors: not_found
POST
/api/game_warning/
Sends a warning to the players in the given pairing that their game has an issue.
Form data parameters:
league={league_tag}
season={season_tag}
white={username}
black={username}
reason={reason_text}
League and season parameters are optional.
Result format:
{
"updated": 1
}
Error format:
{
"updated": 0,
"error": "not_found"
}
Possible errors: no_matching_rounds
, not_found
, ambiguous