Here is a REST api of products, where user can add, find, delete or update a product
For a product we store the following:
- Name of the product
- Type of the product so that we can further use filters if required
- Stock of the product so that we can only show in-stock products to the customer, or API-callers
- Price, it is one of the most important data of product
There are four basic API calls possible so far on the design
API URL: host_name/product
1. GET: This is used to retrieve data about product from database
- We can ask queries in GET form using four variables
- name(string): This filters request on the basis of name of product
example:
host_name/product?name=ayush
- type(integer): This filters request on the basis of type of product
example:
host_name/product?type=1
- price(integer): This filters request on the basis of price of product
example:
host_name/product?price=5000
- stock(integer): This filters request on the basis of stock of product
example:
host_name/product?stock=10
- name(string): This filters request on the basis of name of product
example:
2. POST: This is used to Create new product in the database
url example: host_name/product
- Request Body strictly require these 4 keys:
- name (string)
- price (number)
- stock (number)
- type (number)
3. PUT: This is used to Update existing product in the database with their product id
url example: host_name/product/product_id
- Request Body can consist of following keys with update values:
- name (string)
- price (number)
- stock (number)
- type (number)
4. DELETE: This is used to Delete an existing product from database
url example: host_name/product/product_id
This is hosted on heroku for deployement purposes and I don't have enough money to deploy it on AWS