Base URL
The API is accessible at:API Structure
The E-commerce API is organized into the following main resource groups:/auth- Authentication and user management/products- Product catalog operations/categories- Product category management/cart- Shopping cart operations/orders- Order processing and management
Common Patterns
Request Format
All POST and PUT requests should send data as JSON with theContent-Type: application/json header:
Response Format
All API responses are returned in JSON format. Successful responses typically include:Authentication
Protected endpoints require a JWT token in theAuthorization header:
Rate Limiting
Authentication endpoints (/auth/register, /auth/login) are rate-limited to prevent abuse:
- Window: 15 minutes
- Max requests: 10 per window
- Headers: Rate limit info is returned in standard headers
Security Headers
The API uses Helmet for security headers and implements:- Content Security Policy
- XSS Protection
- HSTS (HTTP Strict Transport Security)
- Frame protection (X-Frame-Options)
CORS Configuration
CORS is configured to accept requests from the frontend application:Request Size Limits
- JSON payloads: Maximum 1MB
- File uploads: Maximum 5MB per file
Pagination
List endpoints support pagination through query parameters:Role-Based Access Control
The API implements two user roles:customer- Default role for registered users, can browse products and manage their own cart and ordersadmin- Administrative role with full access to create, update, and delete resources
403 Forbidden error if accessed with insufficient permissions.
Data Validation
All input data is validated using class-validator. Validation errors return a422 Unprocessable Entity status with details about the validation failures.
Next Steps
- Authentication - Learn how to authenticate and manage user sessions
- Error Handling - Understand error responses and status codes