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.
- Python 3.12
- Django 4.x
- Django REST Framework
- django-filter
- 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
git clone https://github.com/yourusername/ecommerce-api.git
cd ecommerce-api
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
- List All Products
GET /products/
- Retrieve Single Product
GET /products//
- 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
/products/?category=Electronics&min_price=300&max_price=3000



