Registration
POST
https://freshie-api.herokuapp.com/register/
Request Body
{
"key": "c502905e8f6f0b3a8aafd8054e688f1cc4fec401",
"user": {
"id": 6,
"password":"pbkdf2_sha256$260000$Bapflp65ZoA7YIH20MV8Qr$kljzhFs39Xd2bfGKVjPoha9KhP9khhBTiq/xZcNU8Nk=",
"last_login": "2021-06-25T21:38:27.082979+08:00",
"username": "bobby",
"first_name" "bobby",
"last_name": "lee",
"email": "bob@email.com",
"date_joined": "2021-06-25T21:38:26.984507+08:00",
"isPersonalTrainer": false,
"Signed up": "With personal Trainer",
"status": "ok",
}
}
Login
POST
https://freshie-api.herokuapp.com/login/
Request Body
{
"key": "c502905e8f6f0b3a8aafd8054e688f1cc4fec401",
"user": {
"id": 6,
"password":"pbkdf2_sha256$260000$Bapflp65ZoA7YIH20MV8Qr$kljzhFs39Xd2bfGKVjPoha9KhP9khhBTiq/xZcNU8Nk=",
"last_login": "2021-06-25T21:38:27.082979+08:00",
"username": "bobby",
"first_name" "bobby",
"last_name": "lee",
"email": "bob@email.com",
"date_joined": "2021-06-25T21:38:26.984507+08:00",
"isPersonalTrainer": false,
"Signed up": "With personal Trainer",
"status": "ok",
}
}
Profile
GET
https://freshie-api.herokuapp.com/api/<username>
Returns the requesting user's profile information.
{
"id": 1,
"username": "james",
"referralCode": "JAMES1",
"user": {
"id": 1,
"password": "pbkdf2_sha256$260000$gj9PvJqUW4y1ewIf4qpQhR$WppJps88jtXA3H0ybem8i72hh0Ye//uYhMkNPbeGxYI=",
"last_login": "2021-06-25T21:55:04.857808+08:00",
"is_superuser": false, "username": "james",
"first_name": "james",
"last_name": "yeap",
"email": "james@eamil.com",
"is_staff": false,
"is_active": true,
"date_joined": "2021-06-23T17:11:11.774779+08:00",
"isPersonalTrainer": true,
"mealPlans": [ 1, 2 ] }
}
}
Get Custom Recipes
GET
https://freshie-api.herokuapp.com/api/recipes/custom/
Returns a list of recipes created by the user
[
{
"id": 1,
"title": "chicken",
"ingredients": "chicken",
"instructions": "cook it",
"calories": 123,
"servings": 1,
"custom": false,
"author": "james"
},
{
"id": 2,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321, "servings": 1,
"custom": false,
"author": "james"
},
{
"id": 3,
"title": "crab",
"ingredients": "crab",
"instructions": "cook it",
"calories": 213,
"servings": 1,
"custom": false,
"author": "james"
}
]
Search All Recipes
GET
https://freshie-api.herokuapp.com/api/recipes/search/
Returns a list of recipes created by the user and personal trainers.
[
{
"id": 5,
"title": "chicken",
"ingredients": "chicken",
"instructions": "cook it",
"calories": 123,
"servings": 1,
"custom": false,
"author": "bob"
},
{
"id": 2,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321, "servings": 1,
"custom": false,
"author": "james"
},
{
"id": 3,
"title": "crab",
"ingredients": "crab",
"instructions": "cook it",
"calories": 213,
"servings": 1,
"custom": false,
"author": "james"
}
]
Add Recipe
GET
https://freshie-api.herokuapp.com/api/recipes/
Adds a new recipe to the database
Request Body
{
"id": 1,
"title": "chicken",
"ingredients": "chicken and egg",
"instructions": "cook it",
"calories": 123,
"servings": 1,
"custom": false,
"author": "james"
}
Edit Recipe
POST
https://freshie-api.herokuapp.com/api/recipes/edit/<recipeID>
Note: Only the author of the recipe is allowed to make changes to the recipe.
Request Body
{
"title": "crab",
"ingredients": "crab",
"instructions": "cook it",
"calories": 503,
"servings": 1,
"custom": true
}
Delete Recipe
DELETE
https://freshie-api.herokuapp.com/api/recipes/edit/<recipeID>
Deletes the recipe with the recipe ID
Get Meal Plans
GET
https://freshie-api.herokuapp.com/api/<username>/mealplans/
[
{
"id": 1,
"title": "week 1",
"meal":
[
{
"id": 1,
"title": "chicken",
"ingredients": "chicken and egg",
"instructions": "cook it",
"calories": 123,
"servings": 1,
"custom": false,
"author": "james"
},
{
"id": 2,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321,
"servings": 1,
"custom": false,
"author": "james"
}
]
},
{
"id": 8,
"title": "week 2",
"meal":
[
{
"id": 9,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321,
"servings": 1,
"custom": false,
"author": null
},
{
"id": 10,
"title": "crab",
"ingredients": "crab",
"instructions": "cook it",
"calories": 213,
"servings": 1,
"custom": false,
"author": null
}
]
}
]
Add Meal Plan
POST
https://freshie-api.herokuapp.com/<username>/add-mealplan/
Request Body
{
"id": 9,
"title": "Week 24",
"meal":
[
{
"id": 14,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321,
"servings": 1,
"custom": false,
"author": null
},
{
"id": 15,
"title": "fish",
"ingredients": "fish",
"instructions": "cook it",
"calories": 321,
"servings": 1,
"custom": false,
"author": null
}
]
}
Delete Meal Plan
DELETE
https://freshie-api.herokuapp.com/api/<username>/mealplan/<mealPlanID>/
Get Client List
GET
https://freshie-api.herokuapp.com/api/<username>/clients/
Returns a list of clients that a personal trainer has.
[
{
"id":1,
"username":"bob",
"user":{
"id":2,
"password":"pbkdf2_sha256$260000$EsA4WqV9P0BqSIBb4qYVqI$sro4B8EGCzCnKIv/ZyzG/7dBNAdhWYwxZHCtUSA75Is=",
"last_login":"2021-06-24T16:32:13.063393+08:00",
"username":"bob",
"first_name":"bob",
"last_name":"bee",
"email":"",
"date_joined":"2021-06-23T17:19:28.358985+08:00",
"isPersonalTrainer":false,
"mealPlans":[
1
]
},
"personalTrainer":{
"id":1,
"username":"james",
"referralCode":"JAMES1",
"user":"james"
}
},
{
"id":3,
"username":"Q",
"user":{
"id":4,
"password":"pbkdf2_sha256$260000$zWMyFNScojkjtS8hyCYouY$AxrFmC2OEWeR0jmIobWp9pHxIr/vVTHsbA0SD+rQKRI=",
"last_login":"2021-06-23T23:00:39.117705+08:00",
"username":"Q",
"first_name":"Q",
"last_name":"Q",
"email":"Q@email.com",
"date_joined":"2021-06-23T18:14:35.098894+08:00",
"isPersonalTrainer":false,
"mealPlans":[
]
},
"personalTrainer":{
"id":1,
"username":"james",
"referralCode":"JAMES1",
"user":"james"
}
},
{
"id":4,
"username":"bobby",
"user":{
"id":6,
"password":"pbkdf2_sha256$260000$Bapflp65ZoA7YIH20MV8Qr$kljzhFs39Xd2bfGKVjPoha9KhP9khhBTiq/xZcNU8Nk=",
"last_login":"2021-06-25T22:27:05.566278+08:00",
"username":"bobby",
"first_name":"bobby",
"last_name":"lee",
"email":"bob@email.com",
"date_joined":"2021-06-25T21:38:26.984507+08:00",
"isPersonalTrainer":false,
"mealPlans":[
]
},
"personalTrainer":{
"id":1,
"username":"james",
"referralCode":"JAMES1",
"user":"james"
}
}
Get Client Profile
GET
https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/view/
Returns the profile details of a client.
{
"id":4,
"username":"bobby",
"user":{
"id":6,
"password":"pbkdf2_sha256$260000$Bapflp65ZoA7YIH20MV8Qr$kljzhFs39Xd2bfGKVjPoha9KhP9khhBTiq/xZcNU8Nk=",
"last_login":"2021-06-25T22:27:05.566278+08:00",
"username":"bobby",
"first_name":"bobby",
"last_name":"lee",
"email":"",
"date_joined":"2021-06-25T21:38:26.984507+08:00",
"isPersonalTrainer":false,
"mealPlans":[
]
},
"personalTrainer":{
"id":1,
"username":"james",
"referralCode":"JAMES1",
"user":"james"
}
}
Get Meal Plans Assigned To A Client
GET
https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/meal-plans/
Returns the meal plans assigned to a client.
[
{
"id":2,
"title":"week 2",
"meal":[
{
"id":2,
"title":"fish",
"ingredients":"fish",
"instructions":"cook it",
"calories":321,
"servings":1,
"custom":false,
"author":"james"
},
{
"id":3,
"title":"crab",
"ingredients":"crab",
"instructions":"cook it",
"calories":213,
"servings":1,
"custom":false,
"author":"james"
}
]
}
]
Assign a Meal Plan To A Client
POST
https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/assign-meal-plan/
Assigns a meal plan to the client.
Request Body
"week 2 assigned to bobby!"
Delete Client's Meal Plan
DELETE
https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/remove-meal-plan/
Unassigns a meal plan from a client.
Request Body
"Successfully removed week 2 from bobby's meal plans!"
Delete Client
DELETE
https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/remove/
Removes a client from a personal trainer's client list.
"You have successfully removed bobby as your client."
Add Personal Trainer
POST
https://freshie-api.herokuapp.com/api/<username>/add-personal-trainer/
Assigns a personal trainer to a client based on the referralID provided.
Request Body
"James is now your personal trainer!"
Get Calorie Count
GET
https://freshie-api.herokuapp.com/api//<username>/calories
Note: A client will only be able to view his own calorie count.
{
"id": 4,
"dailyCalories": 2000,
"currentCalories": 0,
"client": "bobby"
}
Edit Calorie Count
PATCH
https://freshie-api.herokuapp.com/api/<username>/calories/
Note: Only the client or his personal trainer will be able to update his calories.
Request Body
{
"id": 4,
"dailyCalories": 2000,
"currentCalories": 532,
"client": "bobby"
}
Get History of Meals Consumed
GET
https://freshie-api.herokuapp.com/<username>/consumed-meals/
Returns a list of the consumed meals on the date provided.
Request Body
"title":"chicken",
"ingredients":"chicken and egg",
"instructions":"cook it",
"calories":123,
"servings":1,
"custom":false,
"author":"james"
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
},
{
"id":26,
"mealType":"Supper",
"date":"2021-06-24",
"calories":321,
"meal":{
"id":4,
"title":"fish",
"ingredients":"fish",
"instructions":"cook it",
"calories":321,
"servings":1,
"custom":false,
"author":"james"
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
}
]
Add Consumed Meal
POST
https://freshie-api.herokuapp.com/api/<username>/add-consumed-meal/
Adds a consumed meal.
Request Body
{
"id":18,
"mealType":"Supper",
"date":"2021-06-24",
"calories":123,
"meal":{
"id":1,
"title":"chicken",
"ingredients":"chicken and egg",
"instructions":"cook it",
"calories":123,
"servings":1,
"custom":false,
"author":"james"
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
}
Delete Consumed Meal
DELETE
https://freshie-api.herokuapp.com/api/<username>/consumed-meal/<consumedMealID>/
Deletes a consumed meal.
Get Favourite Meals
GET
https://freshie-api.herokuapp.com/api/<username>/fav-meals/
Returns a list of the client's favourite meals.
[
{
"id":1,
"meal":{
"id":11,
"title":"chicken",
"ingredients":"chicken and egg",
"instructions":"cook it",
"calories":123,
"servings":1,
"custom":false,
"author":null
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
},
{
"id":2,
"meal":{
"id":12,
"title":"fish",
"ingredients":"fish",
"instructions":"cook it",
"calories":321,
"servings":1,
"custom":false,
"author":null
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
}
]
Add Favourite Meal
POST
https://freshie-api.herokuapp.com/api/<username>/add-fav-meal/
Adds an existing recipe to client's favourites.
Request Body
{
"id": 3,
"meal":{
"id":13,
"title":"crab",
"ingredients":"crab",
"instructions":"cook it",
"calories":213,
"servings":1,
"custom":false,
"author":null
},
"client":{
"id":1,
"username":"bob",
"user":"bob",
"personalTrainer":"james"
}
}
Delete Favourite Meal
DELETE
https://freshie-api.herokuapp.com/api/<username>/fav-meal/1/
Removes a recipe from a user's favorite list.
Edit Client's Target Daily Calories
POST
https://freshie-api.herokuapp.com/api/ <username>/client/<clientUsername>/edit-calories/
Allows the personal trainer to change his client's target daily calories.
Request Body