Skip to content

stealacamera/ecommerce-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecommerce API

REST API to store and keep track of categories, products, user carts, orders/sales.

API frontend: https://github.com/stealacamera/ecommerce-api-frontend

API endpoints

Uses JWT authentication.
Methods in italic are only accessible by users.
Methods in bold are only accessible by admins.

User endpoints

http://localhost:5000/api/account/

Endpoint HTTP methods Description
register/ POST
change-password/ PUT Updates password & blacklists current refresh token
change-address/ PUT PATCH Updates user address info (city, street address, zip code)
token-refresh/ POST
login/ POST Enter username & password to log in
logout/ POST Blacklists current refresh token
profile/ GET PUT Get logged-in user's profile; Change username
profile/<slug:username>/ GET Get the specified user's profile

Product endpoints

Filter products by category & rating.
Order products by price & rating.
Search through products by name & description.

Filter reviews by rating.
http://localhost:5000/api/

Endpoint HTTP methods Description
category/ GET POST Returns list of categories
category/<pk>/ GET PUT PATCH DELETE
GET POST Returns list of products
<pk>/ GET PUT PATCH DELETE
<int:product_pk>/reviews/ GET POST Returns reviews for the specified product
<int:product_pk>/reviews/<int:pk>/ GET PUT PATCH DELETE

Cart endpoints

http://localhost:5000/api/cart/

Endpoint HTTP methods Description
GET Returns user cart items
<int:pk>/ GET PUT PATCH DELETE
add/<int:product_pk>/ POST Add specified product to user's cart

Order endpoints

Order sales & orders by date ordered.
http://localhost:5000/api/orders/

Endpoint HTTP methods Description
checkout/ POST Turns cart items to orders, deleting the existing cart
history/ GET Returns the user's placed orders
sales/ GET Returns the user's sales/shop orders
sales/<int:pk>/ GET PUT PATCH

Usage

  • Register Postman register user

  • Change user password Postman PUT user password

  • Change user address info Postman PUT user address

  • Get categories Postman GET categories

  • Get products Postman GET products

  • Create product Postman POST product

  • Create review Postman PSOT review

  • Add product to cart Postman add to cart

  • Get cart Postman GET cart

  • Checkout user cart Postman POST user cart

  • Get user order history Postman GET user order history

  • Get user sales Postman GET user sales

Installation

  1. Clone the repo
git clone https://github.com/stealacamera/ecommerce-api.git
  1. Create and activate a virtual environment
virtualenv <venv name>
<venv name>\Scripts\activate
  1. Install the dependencies
pip install -r requirements.txt
  1. Run migrations and server
python manage.py migrate
python manage.py runserver

About

DRF API for products and ordering

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages