Giter Club home page Giter Club logo

freebay-api's Introduction


The REST API for the FreeBay Web App

Table of Contents

  1. Products Routes
  2. Authorization Routes
  3. User Route
  4. Notifications Route
  5. Bids Routes
  6. Products Won Routes
  7. How to Run a Local Copy
  8. Contact

Products Routes

Get Information on Products

GET /products

Search Parameters to Include in Optional Query String Request:

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

Response:

{
  "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 Information on a Product

Request:

GET /product/:id

Response:

{
  "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"
    }
}

Authorization Routes

Register User

POST /auth/register/

Request:

{
  "email":  "[email protected]",
  "username": "username",
  "password": "password",
  "firstName": "first",
  "lastName": "last"
}

Response:

{ "token":"abcd123" }

Login User

POST /auth/login/

Request:

{
  "email":  "[email protected]",
  "username": "username"
}

Response:

{ "token":"abcd123" }

User Route

Get a Users Information

Request:

GET /users/:username

Response:

{
  "email": "[email protected]",
  "username": "username",
  "firstName": "firstname",
  "lastName": "lastname",
  "imageUrl": "www.google.com",
  "balance": "78",
  "bids": [],
  "productsWon": [],
  "notifications": []
}

Notifications Route

Set the Logged-In User's Notifications to Viewed

Request:

POST /notifications/view/

Response:

{ "success" }

Bids Routes

Check All Bids and Update Any Products if Auction Ended

Request:

GET /bids/check-all-bids-for-ended-auctions

Response:

{
  All bids check for ended auctions. # auctions have ended
}

Get Most Recent Bids

Request:

GET /bids/recent/:num

Response:

[
  {
    "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]"
  }
]

Place a Bid

Request:

POST /bids/:productId/placeBid/:amount

Response:

{ "success" }

Products Won Routes

Get Most Recent Products Won

Request:

GET /products-won/recent/:num

Response:

[
  {
    "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"
  }
]

How to Run a Local Copy

To get a local copy of the API up and running follow these steps:

Clone Repo

  1. 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

Library Installations

  1. After cloning each repo (and unzipping if downloaded), install the libraries in the backend repo.

    npm install

Postgres Installation

  1. Install Postgres.
  2. Create a database named "freebay" in your terminal in the backend directory.
    createdb freebay

Seed Products to Database

  1. 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
  2. Start your server in the appropriate directory and you are done!

Contact

Berkley Olmstead - [email protected] - Linkedin

Project Links:
Live Site
https://github.com/freebay-frontend
https://github.com/freebay-backend

freebay-api's People

Contributors

bolmstead avatar berkleydev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.