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