Skip to content

Latest commit

 

History

History
334 lines (266 loc) · 3.9 KB

API.md

File metadata and controls

334 lines (266 loc) · 3.9 KB

Authentication

endpoint: /auth/login

method: POST

body:

{
  "email": "",
  "password": ""
}

success response

{
  "error": false,
  "data": "token"
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

endpoint: /auth/register

method: POST

body:

{
  "email": "",
  "password": "",
  "full_name": ""
}

success response

{
  "error": false,
  "data": "token"
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

Users

endpoint: api/u/update

method: POST

body:

{
  "full_name": "string(optional)",
  "weight": 50,
  "height": 1.5,
  "age": 22,
  "gender": "M(must be 'M' or 'F')",
  "exerciseIndex": "number",
  "token": ""
}

Note: all parameters are optional, provide only which you want to update

success response

If all parameters(mentioned above) are passed

{
  "error": false,
  "data": {
    "bmi": "number",
    "weightRange": ["number", "number"]
  }
}

If any one parameter is optional (except full_name)

{
  "error": false,
  "data": "Success"
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

endpoint: /api/u/data

method: POST

body:

{
  "token": ""
}

success response

{
  "error": false,
  "data": {
    "full_name": "",
    "age": "",
    "weight": "",
    "height": "",
    "gender": "",
    "bmi": "",
    "bmr": ""
  }
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

Tasks

endpoint: /api/t/initiate

method: POST

body:

{
  "goalWeight": "",
  "perWeekWeightGoal": "",
  "token": ""
}

success response

{
  "error": false,
  "data": {
    "_id": "string(use this as taskId to update this task in future)",
    "caloriesToConsume": "num",
    "drankWater": "num",
    "totalWaterGoal": "num",
    "caloriesConsumed": "num",
    "diet": [
      {
        "foodName": "string",
        "quantity": "num",
        "caloriesGot": "num"
      }
    ],
    "sleep": {
      "sleptAt": "Date",
      "wokeupAt": "Date"
    },
    "workout": [
      {
        "workoutName": "string",
        "caloriesBurnt": "num"
      }
    ]
  }
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

endpoint: /api/t/today

method: POST

body:

{
  "token": ""
}

success response

{
  "error": false,
  "data": {
    "_id": "string(use this as taskId to update this task in future)",
    "caloriesToConsume": "num",
    "drankWater": "num",
    "totalWaterGoal": "num",
    "caloriesConsumed": "num",
    "diet": [
      {
        "foodName": "string",
        "quantity": "num",
        "caloriesGot": "num"
      }
    ],
    "sleep": {
      "sleptAt": "Date",
      "wokeupAt": "Date"
    },
    "workout": [
      {
        "workoutName": "string",
        "caloriesBurnt": "num"
      }
    ]
  }
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}

endpoint: /api/t/update

method: POST

body:

Please provide only 1 attribute to update, It will ignore other anyways

{
  "token": "must",
  "taskId": "must",

  "water": "number",
  "totalWaterGoal": "number",
  "diet": [
    {
      "foodName": "string",
      "quantity": "num",
      "caloriesGot": "num"
    }
  ],
  "sleep": {
    "sleptAt": "Date",
    "wokeupAt": "Date"
  },
  "workout": [
    {
      "workoutName": "string",
      "caloriesBurnt": "num"
    }
  ]
}

success response

{
  "error": false,
  "data": ""
}

error response

{
  "error": true,
  "internalError": "boolean",
  "data": "Reason"
}