API Documentation - nicopierson/hotpotato GitHub Wiki
API-Routes
Goal: Choose a couple of API Routes to implement.
To make a REST API request you may combine a URL with an HTTP method GET
, POST
, PUT
, or DELETE
. Logged in users may only POST
, PUT
, DELETE
owned Lists and Tasks, which are dynamically rendered AJAX requests. Any verification will be validated with session authentication.
Routes to implement
Resources |
---|
1. Recipes |
2. Likes |
3. Comments |
4. Tags |
5. Users |
Recipes
A logged in user can GET
any Recipes available in the database:
Path | HTTP Verb | Description |
---|---|---|
/api/recipes |
GET |
request all recipe collections |
/api/recipes/users/:id |
GET |
request all recipe collections owned by a specific user |
/api/recipes/:id |
GET |
request a single recipe by the id number |
A logged in user can POST
, PUT
, or DELETE
only Recipes owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/recipes |
POST |
create a new recipe |
/api/recipes/:id |
PUT |
edit the recipe with the id |
/api/recipes/:id |
DELETE |
delete the recipe with the id |
Likes
A logged in user can GET
any likes available in the database:
Path | HTTP Verb | Description |
---|---|---|
/api/likes/:id/ |
GET |
request a single like using a like id |
/api/likes/recipes/:id/ |
GET |
request all likes from a single recipe based on id |
/api/likes/users/:id/ |
GET |
request all like collections owned by a specific user |
A logged in user can POST
, PUT
, or DELETE
only likes owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/likes/recipes/:id |
POST |
like a recipe |
/api/likes/:id |
DELETE |
delete the like with the id |
Routes for future reference
Comments
A logged in user can GET
any Comments available in the database:
Path | HTTP Verb | Description |
---|---|---|
/api/comments |
GET |
request all comments |
/api/comments/recipes/:id |
GET |
request all comments in a recipe |
/api/comments/users/:id |
GET |
request all comment collections owned by a specific user |
/api/comments/:id |
GET |
request comment based on comment id |
A logged in user can POST
, PUT
, or DELETE
only Comments owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/comments/recipes/:id |
POST |
create a new comment belonging to a recipe |
/api/comments/:id |
PUT |
edit the comment by the id |
/api/comments/:id |
DELETE |
delete the comment with the id |
Follows
A logged in user can GET
a list of their followers:
Path | HTTP Verb | Description |
---|---|---|
/api/follows/:id/ |
GET |
request a single follower using follow id |
/api/follows/users/:id/ |
GET |
request all follows collections owned by a specific user |
A logged in user can POST
, PUT
, or DELETE
only follower owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/follows/users/:id |
POST |
follow a user |
/api/follows/users/:id |
DELETE |
remove the follow based on the user/follow owner id |
User
Path | HTTP Verb | Description |
---|---|---|
/api/users |
GET |
request all profile collections |
/api/users/:id |
GET |
request a specific profile |
A logged in user can POST
, PUT
, or DELETE
only follower owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/users/:id/bio |
PUT |
change user bio |
Reference for later
Tags
A logged in user can GET
any tags available in the database:
Path | HTTP Verb | Description |
---|---|---|
/api/tags |
GET |
request all tag collections |
/api/tags/recipes/:id |
GET |
request all tags in a recipe |
/api/tags/users/:id |
GET |
request all tag collections labeled by a specific user |
/api/tags/:id/recipes |
GET |
request all recipes by a tag id |
A logged in user can POST
, PUT
, or DELETE
only tags owned by the same user:
Path | HTTP Verb | Description |
---|---|---|
/api/tags |
POST |
create a new tag |
/api/tags/recipes/:id |
POST |
create a new tag belonging to a recipe |
/api/tags/:id |
PUT |
edit the tag by the id |
/api/tags/:id |
DELETE |
delete the tag by the id |