API

Some documentation

Registration

POST https://freshie-api.herokuapp.com/register/

Request Body

Name
Type
Description

username

string

bobby

firstName

string

bobby

lastName

string

lee

email

string

bob@email.com

pasword1

string

bobbob123

password2

string

bobbob123

isPersonalTrainer

boolean

false

referralCode

string

JAMES1

calories

number

2000

{
    "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

Name
Type
Description

username

string

bobby

password

string

bobbybobby123

Profile

GET https://freshie-api.herokuapp.com/api/<username>

Returns the requesting user's profile information.

Get Custom Recipes

GET https://freshie-api.herokuapp.com/api/recipes/custom/

Returns a list of recipes created by the user

Search All Recipes

GET https://freshie-api.herokuapp.com/api/recipes/search/

Returns a list of recipes created by the user and personal trainers.

Add Recipe

GET https://freshie-api.herokuapp.com/api/recipes/

Adds a new recipe to the database

Request Body

Name
Type
Description

title

string

chicken

ingredients

string

chicken and egg

instructions

string

cook it

calories

number

123

servings

number

1

custom

boolean

false

author

string

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

Name
Type
Description

title

string

crab

ingredients

string

crab

instructions

string

cook it

calories

number

503

servings

number

1

custom

boolean

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/

Add Meal Plan

POST https://freshie-api.herokuapp.com/<username>/add-mealplan/

Request Body

Name
Type
Description

title

string

Week 24

meals

array

[2, 9]

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.

Get Client Profile

GET https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/view/

Returns the profile details of a client.

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.

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

Name
Type
Description

mealPlanID

number

2

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

Name
Type
Description

mealPlanID

number

Delete Client

DELETE https://freshie-api.herokuapp.com/api/<username>/client/<clientUsername>/remove/

Removes a client from a personal trainer's client list.

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

Name
Type
Description

referralCode

string

JAMES1

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.

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

Name
Type
Description

currentCalories

number

532

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

Name
Type
Description

day

number

24

month

number

6

year

number

2021

Add Consumed Meal

POST https://freshie-api.herokuapp.com/api/<username>/add-consumed-meal/

Adds a consumed meal.

Request Body

Name
Type
Description

recipeID

string

18

mealType

string

Supper

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.

Add Favourite Meal

POST https://freshie-api.herokuapp.com/api/<username>/add-fav-meal/

Adds an existing recipe to client's favourites.

Request Body

Name
Type
Description

recipeID

number

3

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

Name
Type
Description

calories

number

2100

Last updated

Was this helpful?