This is a comprehensive e-commerce API built with Laravel, providing all the necessary endpoints for building mobile and web applications. The API includes authentication, product management, cart functionality, order processing, reviews, and more.
The API is fully documented using Swagger/OpenAPI 3.0 specification. You can access the interactive documentation at:
GET /api/documentation
The API uses Laravel Sanctum for authentication. After registration or login, you'll receive a bearer token that should be included in the Authorization header for protected endpoints.
Authorization: Bearer {your-token-here}
{your-domain}/api/ecommerce
POST /register- Register a new customerPOST /login- Login customerPOST /logout- Logout customer (requires auth)POST /forgot-password- Request password resetPOST /reset-password- Reset password
GET /products- Get products with advanced filteringGET /products/featured- Get featured productsGET /products/search- Search products with suggestionsGET /products/{id}- Get single productGET /products/{id}/related- Get related productsGET /products/{id}/reviews- Get product reviews
GET /categories- Get all categoriesGET /categories/{id}- Get single categoryGET /categories/{id}/products- Get category productsGET /brands- Get all brandsGET /brands/{id}- Get single brandGET /brands/{id}/products- Get brand products
POST /cart/add- Add product to cartGET /cart- Get cart contentsGET /cart/count- Get cart item countPUT /cart/{item}- Update cart itemDELETE /cart/{item}- Remove cart itemDELETE /cart/clear- Clear entire cart
POST /orders- Create new orderGET /orders/{id}- Get order detailsPOST /orders/{id}/cancel- Cancel orderGET /orders/{id}/track- Track order
POST /products/{id}/reviews- Create product reviewPUT /reviews/{id}- Update reviewDELETE /reviews/{id}- Delete review
GET /customer/profile- Get customer profilePUT /customer/profile- Update customer profileGET /customer/orders- Get customer ordersGET /customer/orders/{id}- Get specific order details
GET /addresses- Get customer addressesPOST /addresses- Create new addressPUT /addresses/{id}- Update addressDELETE /addresses/{id}- Delete address
GET /wishlist- Get wishlist itemsPOST /wishlist/{product}- Add to wishlistDELETE /wishlist/{product}- Remove from wishlist
POST /coupon/apply- Apply coupon to cartDELETE /coupon/remove- Remove applied coupon
GET /shipping/methods- Get available shipping methodsPOST /shipping/calculate- Calculate shipping cost
GET /payment/methods- Get available payment methodsPOST /payment/process- Process payment (requires auth)
All requests and responses are in JSON format.
{
"data": {...},
"message": "Success message"
}{
"message": "Error message",
"errors": {
"field": ["Validation error message"]
}
}{
"data": [...],
"links": {
"first": "...",
"last": "...",
"prev": null,
"next": "..."
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"per_page": 15,
"to": 15,
"total": 75
}
}The products endpoint supports advanced filtering:
category- Filter by category IDbrand- Filter by brand IDsearch- Search in name, description, SKUmin_price- Minimum price filtermax_price- Maximum price filterin_stock- Filter only in-stock productssort_by- Sort by:price_low_high,price_high_low,name,created_atsort_order- Sort order:asc,descper_page- Items per page (default: 15)
Example:
GET /api/ecommerce/products?category=1&min_price=10&max_price=100&sort_by=price_low_high&per_page=20
200- Success201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found409- Conflict422- Validation Error500- Internal Server Error
The API implements rate limiting to prevent abuse. Default limits:
- 60 requests per minute for authenticated users
- 30 requests per minute for guest users
You can test the API using the provided test suite:
php artisan testFor support and questions, please contact:
- Email: jmrashed@gmail.com
- GitHub: https://github.com/jmrashed/ecommerce
This API is open-sourced software licensed under the MIT license.