Skip to content

Latest commit

 

History

History
104 lines (68 loc) · 2.18 KB

File metadata and controls

104 lines (68 loc) · 2.18 KB

🛒 E-commerce Product API

This is a RESTful API for an e-commerce application that allows users to view and search for products based on filters such as price, category, and availability. It also supports sorting by price and name.


🔧 Tech Stack

  • Python 3.12
  • Django 4.x
  • Django REST Framework
  • django-filter

📦 Features

  • Product & Category models
  • Filter products by:
    • Category
    • Price range (min/max)
    • Availability
  • Sort products by:
    • Name (A–Z or Z–A)
    • Price (Low–High or High–Low)
  • Browsable API support via DRF
  • Combined filtering and sorting in a single request

⚙️ Setup Instructions

1. Clone the Repository

git clone https://github.com/yourusername/ecommerce-api.git
cd ecommerce-api

2. Create a Virtual Environment

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Apply Migrations

python manage.py migrate

5. Create a Superuser(Creating test products

python manage.py createsuperuser

6. Run the Development Server

python manage.py runserver

API Endpoints

  • List All Products

GET /products/

image

  • Retrieve Single Product

GET /products//

image

  • Query Parameters
Parameter Type Description
category string Filter by category name
available bool true or false
min_price float Minimum price
max_price float Maximum price
ordering string price, -price, name, -name

Examples:

/products/?available=true&category=Electronics&ordering=-price

image

/products/?category=Electronics&min_price=300&max_price=3000

image