2 Leaderboard API
Tom Bloor edited this page 2017-06-13 23:14:15 +01:00

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
  • all_time_total
  • all_time_count

Response JSON

Success

Response code of 200 OK

{
  success : true,
  leaderboard : [
    {
      display_name : <User Display Name>,
      value : <leaderboard value>,
      trend : <trend>,
      position : <position>
    },
    ...
  ],
  user_position : <Current User Position>
}

Where trend is:

  • 1 : Descending the Leaderboard (approaching last)
  • 0 : No change in Leaderboard position
  • -1 : Ascending the Leaderboard (approaching first)

And user_position is the place of the user in the leaderboard - a result of 0 means they have no position.

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