diff --git a/User-Stats-API.md b/User-Stats-API.md new file mode 100644 index 0000000..21c556f --- /dev/null +++ b/User-Stats-API.md @@ -0,0 +1,57 @@ +# User Stats API + +## `POST /api/stats` + +Takes an `application/json` payload. Returns minor stats for today. + +### Request JSON + +``` +{ + session_key : +} +``` + +### Response JSON + +#### Success + +Response code of `200 OK` + +``` +{ + success : true, + today_sum : , + today_count : , + week_sum : , + week_count : , + month_sum : , + month_count : + global_sum : , + global_count : +} +``` + +#### 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