Created Leaderboard API (markdown)
parent
3c2a411c21
commit
cdaed75d8d
1 changed files with 78 additions and 0 deletions
78
Leaderboard-API.md
Normal file
78
Leaderboard-API.md
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
# Transaction Upload API
|
||||||
|
|
||||||
|
## `POST /api/stats/leaderboard`
|
||||||
|
|
||||||
|
Takes an `application/json` post request.
|
||||||
|
|
||||||
|
### Request JSON
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
session_key : <current session key>,
|
||||||
|
type : <leaderboard 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 : <User Display Name>,
|
||||||
|
value : <leaderboard value>,
|
||||||
|
trend : <trend>
|
||||||
|
},
|
||||||
|
...
|
||||||
|
],
|
||||||
|
user_position : <Current 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 message>
|
||||||
|
error : <error type>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
Reference in a new issue