Created User Stats API (markdown)
parent
34ddacf1a6
commit
abfffa1676
1 changed files with 57 additions and 0 deletions
57
User-Stats-API.md
Normal file
57
User-Stats-API.md
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# User Stats API
|
||||||
|
|
||||||
|
## `POST /api/stats`
|
||||||
|
|
||||||
|
Takes an `application/json` payload. Returns minor stats for today.
|
||||||
|
|
||||||
|
### Request JSON
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
session_key : <session_key>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Response JSON
|
||||||
|
|
||||||
|
#### Success
|
||||||
|
|
||||||
|
Response code of `200 OK`
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
success : true,
|
||||||
|
today_sum : <sum of transactions for user>,
|
||||||
|
today_count : <count of transactions for user>,
|
||||||
|
week_sum : <sum of the last 7 days for user>,
|
||||||
|
week_count : <count of the last 7 days for user>,
|
||||||
|
month_sum : <sum of the last 30 days for user>,
|
||||||
|
month_count : <count of the last 30 days for user>
|
||||||
|
global_sum : <sum of global transactions>,
|
||||||
|
global_count : <count of global transactions>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 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