From abfffa16760b57faea8d6b15f51fa764ce42bb8d Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 16 May 2017 21:50:52 +0100 Subject: [PATCH] Created User Stats API (markdown) --- User-Stats-API.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 User-Stats-API.md 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