user:
{
"id": 1,
"username": "admin",
"password": "password"
}
recipe category:
{
"id": 1,
"title": "lunch"
}
recipes:
{
"id": 1,
"title": "chicken noodle soup",
"source": "grandma",
"category_id": 1,
"user_id": 1
}
ingredients:
{
"id": 1,
"name": "eggs",
"description": "cage free"
}
recipe_ingredients:
{
"recipe_id": 1,
"ingredient_id": 1,
"quantity": 5,
"units": "teaspoons"
},
{
"recipe_id": 1,
"ingredient_id": 2,
"quantity": 1,
"units": "pounds"
}
Note: recipe_id and ingredient_id create the ingredient to recipe relationship.
instructions:
{
"id": 1,
"step": 1,
"description": "Preheat the oven",
"recipe_id": 1
}
The following endpoints serve all CRUD functionality for the Secret Family Recipes Cookbook backend.
/api/auth/register
Required data for registering a new user:
- Username (unique)
- Password (unique)
Returns newly created user id, username, and token.
/api/auth/login
Required data for logging in a user:
- Username
- Password
Returns user id, username, and token.
/api/recipes
Requires a valid token.
Returns list of all existing recipes.
/api/recipes/:id
Requires a valid token.
Returns a recipe based on the id parameter.
/api/ingredients
Requires a valid token.
Returns list of all existing ingredients.
/api/ingredients/:id
Requires a valid token.
Returns an ingredient based on the id parameter.
/api/recipes/categories
Requires a valid token.
Returns a list of all existing recipe categories.
/api/recipes/:id/steps
Requires a valid token.
Returns a list of all steps / instructions for a recipe based on the recipe's id.
/api/recipes/:id/ingredients
Requires a valid token.
Returns a list of all ingredients for a recipe based on the recipe's id.
/api/recipes
Requires a valid token.
Required fields for creating a recipe:
- title
- source
- category_id
- user_id
data schema:
{
"id": 1,
"title": "cheeseburgers",
"source": "aunt joy",
"category_id": 1,
"user_id": 1
}
Returns the created recipe.
/api/categories
Requires a valid token.
Required fields for creating a recipe category:
- title
data schema:
{
"title": "breakfast"
}
Returns the created recipe category.
/api/ingredients
Requires a valid token.
Required fields for adding a new ingredient to the database:
- name
- description
data schema:
{
"name": "cheese",
"description": "pepperjack"
}
Returns the created ingredient.
/api/recipes/instructions
Requires a valid token.
Required fields for adding a new recipe instruction / step:
- recipe_id
- step #
- description
{
"step": 2,
"description": "Preheat the oven",
"recipe_id": 1
}
Returns the created instruction / step.
/api/recipes/:id
Requires a valid token.
There are no required fields to modify a recipe. All fields can be edited.
data schema:
{
"title": "chili",
"source": "grandpa",
"category_id": 2,
"user_id": 1
}
Returns the updated recipe.
/api/recipes/categories/:id
Requires a valid token.
Required fields for modifying / updating a recipe category:
- title
{
"title": "appetizers"
}
Returns the updated recipe category.
/api/ingredients/:id
Requires a valid token.
At least one of the following fields is required to modify and ingredient.
- name
- description
{
"name": "beef",
"description": "cubed"
}
/api/recipes/:id
Requires a valid token.
There are no require fields for deleting a recipe.
/api/recipes/categories/:id
Requires a valid token.
There are no required fields for deleting a recipe category.
/api/ingredients/:id
Requires a valid token.
There are no required fields for deleting an ingredient.
Returns deleted ingredient's id.