API Documentation

Toys API

HTTP Method Route Description Parameters / Request Body
GET /toys Returns a list of toys according to the query parameters.
GET /toys/prices Returns a list of toys filtered by price range.
GET /toys/single/:id Returns a single toy by its ID.
GET /toys/search Returns a list of toys matching a search query.
GET /toys/category/:catName Returns a list of toys by category.
POST /toys Adds a new toy.
Token is required!
  • Request Body: Toy data to be added in the following format.
  • price: 1-999999
  • img_url is allowed and not required
  • {
    name: String,
    info: String,
    category: String,
    price: Number,
    img_url: String 
    }
                        
PUT /toys/:idEdit Updates an existing toy.
Token is required!
  • idEdit: the ID of the toy to update.
  • Request Body: Toy data to be updated in the following format.
  • price: 1-999999
  • img_url is allowed and not required
  • {
    name: String,
    info: String,
    category: String,
    price: Number,
    img_url: String
    }
                    
DELETE /toys/:idDel Deletes a toy by its ID.
Token is required!
  • idDel: the ID of the toy to delete.

Users API

HTTP Method Route Description Request Body
GET /users Test endpoint to check if the server is running N/A
GET /users/userInfo Get the information for the authenticated user (requires authentication) N/A
POST /users Create a new user { name: String, email: String, password: String }
POST /users/login Authenticate a user and receive a JWT token in response { email: String, password: String }

Users/Admin Token Abillities

Admin Default User
Has the ability to add new toys to the system Has the ability to add new toys to the system
Can edit all information related to any toy in the system Can only edit information related to toys they have created or are associated with their account
Has the ability to delete all toys from the system Can only delete toys that they have created or are associated with their account