The REST API for the FreeBay Web App
- Products Routes
- Authorization Routes
- User Route
- Notifications Route
- Bids Routes
- Products Won Routes
- How to Run a Local Copy
- Contact
GET /products
Query Name | Type | Example | Description |
---|---|---|---|
name | String | iPod | Products that contain this product name |
category | String | Home and Household | Products that contain this category |
sub_category | String | Movies and TV | Products that contain this subcategory |
description | String | 70" 4k Television | Products that contain this description |
rating | Number | 4.2 | Products that have at least this rating |
num_of_ratings | Number | 302 | Products that have at least this number of ratings |
{
"products": [
{
"id": 2145,
"name": "MANGOPOP Women's Mock Turtle Neck Sleeveless Tank Top"
"category": "Fashion",
"subCategory": "Womens",
"description": "Great stretchy fabric Modal Spandex",
"rating": "5",
"numOfRatings": 1049,
"imageUrl": "https://images-na.ssl-images-amazon.com/images/I/511iUnHsTXL._AC_UX342_.jpg",
"startingBid": "13",
"auctionEndDt": "2021-05-04T17:50:43.037Z",
"auctionEnded": false,
"bidderEmail": [email protected],
"bidderFirstName": Jim,
"bidderLastName": Bob,
"bidderUsername": Jimbo,
"bidPrice": 15,
"bidId": 2,
"isHighestBid": true,
"wasWinningBid": false
}
],
"numOfProductsInAuction": 1
}
GET /product/:id
{
"productResult":
{
"id":7,
"name":"Wireless Indoor Cam with Night Vision",
"category":"Electronics",
"subCategory":"Photo",
"description":"This is a great camera.",
"rating":"4",
"numOfRatings":1101,
"imageUrl":"https://images-na.ssl-images-amazon.com/images/I/518Ngm46uuL._AC_SY450_.jpg",
"startingBid":"20",
"auctionEndDt":"2021-04-14T23:38:53.238Z",
"auctionEnded":true,
"bidderEmail":"[email protected]",
"bidPrice":"35",
"isHighestBid":true,
"bidId":27,
"wasWinningBid":true,
"bidderUsername":"Bolmstead",
"numOfBids":"2"
}
}
POST /auth/register/
{
"email": "[email protected]",
"username": "username",
"password": "password",
"firstName": "first",
"lastName": "last"
}
{ "token":"abcd123" }
POST /auth/login/
{
"email": "[email protected]",
"username": "username"
}
{ "token":"abcd123" }
GET /users/:username
{
"email": "[email protected]",
"username": "username",
"firstName": "firstname",
"lastName": "lastname",
"imageUrl": "www.google.com",
"balance": "78",
"bids": [],
"productsWon": [],
"notifications": []
}
POST /notifications/view/
{ "success" }
GET /bids/check-all-bids-for-ended-auctions
{
All bids check for ended auctions. # auctions have ended
}
GET /bids/recent/:num
[
{
"id": 1554,
"name": "Cutting Mat for Cricut Maker/Explore Air",
"category": "Sports, Hobbies, & Misc",
"subCategory": "Arts and Crafts",
"description": "Xinart cutting mat x ",
"rating": "2",
"imageUrl": "https://images-na.ssl-images-amazon.com/images/I/61BoGCWperL._AC_SY450_.jpg",
"auctionEndDt": "2021-04-27T10:47:28.962Z",
"auctionEnded": false,
"bidId": 40,
"bidPrice": "2",
"bidTime": "2021-04-19T02:39:43.311Z",
"isHighestBid": true,
"wasWinningBid": false,
"bidderEmail": "[email protected]",
"username": "username",
"email": "[email protected]"
}
]
POST /bids/:productId/placeBid/:amount
{ "success" }
GET /products-won/recent/:num
[
{
"id":1174,
"name":"Workout Gear",
"category":"Fashion",
"subCategory":"Womens",
"description":"This is a great product!'",
"rating":"2",
"imageUrl":"https://images-na.ssl-images-amazon.com/images/I/61N4IJZixJL._AC_UX385_.jpg",
"auctionEndDt":"2021-04-25T00:06:10.597Z",
"auctionEnded":true,"bidPrice":"22",
"wonTime":"2021-04-26T03:06:26.161Z",
"username":"asdf",
"email":"[email protected]",
"userImageUrl":"fasdfasdf"
}
]
To get a local copy of the API up and running follow these steps:
- Clone the backend repo to a separate directory by going to https://github.com/freebay-backend. From there, click Download Zip again from the green Code button at the top of the page or enter the following in a separate directory in your terminal:
git clone https://github.com/Bolmstead/freebay-backend.git
-
After cloning each repo (and unzipping if downloaded), install the libraries in the backend repo.
npm install
- Install Postgres.
- Create a database named "freebay" in your terminal in the backend directory.
createdb freebay
-
Run the following command in your terminal in the backend directory to create the database tables and seed products to database.
psql -d freebay -f SeedTablesAndProducts.sql
-
Start your server in the appropriate directory and you are done!
Berkley Olmstead - [email protected] - Linkedin
Project Links:
Live Site
https://github.com/freebay-frontend
https://github.com/freebay-backend