From cdaed75d8dcd8f06a043a4f259ac9509eb716854 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Mon, 12 Jun 2017 20:42:48 +0100 Subject: [PATCH] Created Leaderboard API (markdown) --- Leaderboard-API.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Leaderboard-API.md diff --git a/Leaderboard-API.md b/Leaderboard-API.md new file mode 100644 index 0000000..deab7b5 --- /dev/null +++ b/Leaderboard-API.md @@ -0,0 +1,78 @@ +# Transaction Upload API + +## `POST /api/stats/leaderboard` + +Takes an `application/json` post request. + +### Request JSON + +``` +{ + session_key : , + type : , +} +``` + +Where type is one of: + +* `daily_total` +* `daily_count` +* `weekly_total` +* `weekly_count` +* `monthly_total` +* `monthly_count` +* `global_total` +* `global_count` + +### Response JSON + +#### Success + +Response code of `200 OK` + +``` +{ + success : true, + leaderboard : [ + { + display_name : , + value : , + trend : + }, + ... + ], + user_position : +} +``` + +Where trend is: + +* `1` : Climbing the Leaderboard +* `0` : No change in Leaderboard position +* `-1` : Descending the Leaderboard + +And `user_position` is the place of the user in the leaderboard - *zero indexed*! + +#### Failure + +If something is missing from the request, or is invalid, you will get a response code of `400 BAD REQUEST` and the following: + +``` +{ + success : false, + message : + error : +} +``` + +If there was a server error, you will get a `500 SERVER ERROR` and possibly the following: + +``` +{ + success : false, + message : 'An unknown error occurred when adding the transaction' + error : 'server_error' +} +``` + +The error messages should describe what was wrong with the submission \ No newline at end of file