Skip to content

API Documentation

Meitong Qu edited this page Nov 16, 2021 · 5 revisions

api/auth

  • GET api/auth/ - authenticates a user.
  • POST api/auth/login - logs a user in.
  • GET api/auth/logout - logs a user out.
  • POST api/auth/signup - creates a new user and logs them in.
  • GET api/auth/unauthorized - returns unauthorized JSON when flask-login authentication fails.

api/users

  • GET api/users/ - get all users
  • GET api/users/:userId - get the user by Id.
  • POST api/users/:userId - edit the user's profile.
  • DELETE api/users/:userId - delete the user.

api/recipes

View Recipe(s)

  • GET api/recipes/ - get all recipes.

  • GET api/recipes/recent - get most recently created 5 recipes.

  • GET api/recipes/previous - get all recipes ordering from newest to oldest created at times.

  • GET api/recipes/:recipeId - get the recipe per ID.

  • GET api/recipes/my_plage/:recipeId - get all comments liked by the logged-in user.

  • GET api/recipes/tag - get all recipes with same tag.

Create, edit and delete Recipes

  • POST api/recipes - create new recipe and its associate tags, ingredients, instructions, media.
  • GET api/recipes/edit/:recipeId - get an edit form, with pre-filled information of recipe and its associate tags, ingredients, instructions, media.
  • POST api/recipes/edit/:recipeId - edit recipe and its associate tags, ingredients, instructions, media.
  • DELETE api/recipes/delete/:recipeId - delete recipe and its associate tags, ingredients, instructions, media.

Comments

  • GET api/recipes/comments - get all comments.
  • POST api/recipes/comments - create comments.
  • PATCH api/recipes/comments/:commentId - edit a comment.
  • DELETE api/recipes/comments/:commentId - delete a comment.

api/likes

  • POST api/likes/:recipeId - create likes to the recipe if there is no like by the current user, otherwise unlike it.
  • GET api/likes/:recipeId - check if the recipe is liked by the logged-in user.
  • GET api/likes/ - get all likes.

api/search

  • GET api/search/:searchTerm - return search result of recipes per searchTerm

api/tags

  • GET api/tags/ - return all tags joined with recipes
  • GET api/tags/random - return all tags joined with recipes in a random order.

Clone this wiki locally