The Favorite API supports basic CRUD operations favorited recipes
Used to create a new favorite recipe
URL : /v1/favorite/create/<username>
Methods : POST
Auth required : YES
Data constraints
{
"recipe_name": "recipe name",
"recipe_id": "unique recipe id",
"picture": "url of recipe picture"
}
Data example
{
"recipe_name": "chicken",
"recipe_id": "400",
"picture": "google.com"
}
Code : 200 OK
Content example
{
"recipe_name": "chicken",
"recipe_id": "400",
"picture": "google.com"
}
Condition : If can't be found
Code : 404 Not Found
Content :
{
"error": "requested user not found"
}
Condition : If favorite recipe couldn't be created or saved
Code : 400 BAD REQUEST
Content :
{
"error": "could not favorite requested recipe"
}
Used to get all favorite recipes associated with a given user
URL : /v1/favorite/<username>
Methods : GET
Auth required : YES
Code : 200 OK
Content example
{
"favorites": [{
"picture": "google.com",
"recipe_id": 400,
"recipe_name": "chicken"
}, {
"picture": "google.com",
"recipe_id": 401,
"recipe_name": "chicken"
}, {
"picture": "google.com",
"recipe_id": 402,
"recipe_name": "chicken"
}]
}
Condition : If can't be found
Code : 404 Not Found
Content :
{
"error": "requested user not found"
}
Removes favorited recipe from the database for a particular user
URL : /v1/favorite/delete/<username>?recipe_id=<recipe_id>
Methods : DELETE
Auth required : YES
Code : 200 OK
Content example
{
"deleted": "<recipe_id>"
}
Condition : If the username passed does not correspond to a user in the db
Code : 404 NOT FOUND
Content :
{
"error": "requested user not found"
}
Condition : The requested favorited recipe could not be deleted
Code : 400 BAD REQUEST
Content :
{
"error": "Deletion unsuccessful"
}