Overview
The E-commerce API provides powerful filtering, searching, and pagination capabilities to help you retrieve exactly the data you need. These features are built on Django REST Framework and django-filters.Pagination
All list endpoints use Limit-Offset pagination by default.Configuration
Pagination settings are defined inconfig/settings.py:167-182:
Parameters
Number of results to return per page
Starting position in the result set
Example Requests
Response Format
Paginated responses include metadata:Total number of items across all pages
URL for the next page (null if no more pages)
URL for the previous page (null if on first page)
Array of items for the current page
Calculating Pages
Filtering
Filter results by specific field values using query parameters.Global Configuration
Product Filtering
The Product list endpoint supports filtering by multiple fields. Location:catalogue/views.py:80
Available Filters
Filter by category ID
Filter by availability (
true or false)Filter by store/vendor ID
Example Requests
Category Filtering
Products can also be filtered by category slug through the URL path: Location:catalogue/urls.py:17
Example
This approach uses the category slug instead of numeric ID, making URLs more readable.
Search
Perform text-based searches across multiple fields.Product Search
The Product list endpoint searches across multiple fields: Location:catalogue/views.py:81
Search Fields
name- Product namecategory__name- Category name (related field)label- Product labelstore__brand_name- Store brand name (related field)
Double underscores (
__) indicate searches across related models (Django’s lookup syntax).Example Requests
Category Search
Search categories by name: Location:catalogue/views.py:35
Combining Features
You can combine filtering, searching, and pagination in a single request.Complex Query Example
- Searches for “wireless” across name, category name, label, and brand
- Filters to category 5
- Filters to available products only
- Filters to store 3
- Returns 20 results (page 3)
Response Example
Ordering
Products are ordered by default ordering specified in the model.Default Product Ordering
Location:catalogue/models.py:56-57
total_sold(descending) - Most popular firstrating(descending) - Highest rated first
Default Order Ordering
Location:orders/models.py:55
Advanced Filtering Patterns
Building Dynamic Queries
Here are common patterns for building queries:Marketplace View (All Stores)
Marketplace View (All Stores)
Single Store Catalog
Single Store Catalog
Category Browse
Category Browse
Store Category View
Store Category View
Search Results
Search Results
Inventory Management
Inventory Management
Performance Tips
Use Appropriate Limits
Set
limit based on your UI needs. Smaller pages load faster and reduce bandwidth.Specific Filters
Add filters like
is_available=true or store=X to reduce result sets.Index-Friendly Queries
Filters on indexed fields (category, is_available, store) are optimized.
Avoid Deep Pagination
Large offset values (e.g., offset=10000) can be slow. Consider alternative approaches for deep pagination.
Error Handling
Invalid Filter Values
Invalid Boolean
Use
true/false, 1/0, or True/False for boolean parameters.Implementation Reference
View Configuration
Here’s how filtering and search are configured in the ProductListView: Location:catalogue/views.py:73-86
filter_queryset() method automatically applies:
- DjangoFilterBackend (for
filterset_fields) - SearchFilter (for
search_fields)
Next Steps
Product Endpoints
Explore the Product API endpoints
Data Models
Learn more about the data models