Laravel e-commerce API documentation
Laravel e-commerce API documentation
Maaajammul
COMMERCE API
REST API for E-Commerce platform with admin panel integration.
#BuiltWithLaravel
Introduction
Welcome to the E-commerce API User Guide. This API is designed to
help developers integrate powerful e-commerce functionalities into
their applications. Built using Laravel, the API provides secure, scalable,
and efficient ways to manage products, orders, users, and more.
Key Features:
User registration and authentication
Secure API with token-based authentication
Getting Started
Installation:
To start using the E-commerce API, clone the repository and set up
the environment:
git clone https://github.com/Maaz0313/laravel-react-
ecom-api.git
cd laravel-react-ecom-api
composer install cp .env.example .env
php artisan key:generate
Prerequisites:
PHP 8.2+
MySQL 8+
Composer 2.x
Node.js & npm (for frontend assets if needed)
API Authentication:
The API uses Laravel Sanctum for authentication. To set it up, run:
php artisan migrate
php artisan serve
Verify Email
POST /api/verify-otp
Request Body:
{
"otp": "Your OTP"
}
Response:
{
"success": true,
"message": " Email verified successfully."
}
Login
POST /api/login
Request Body:
{
"email": "[email protected]",
"password": "password123"
}
Response:
{
"token": "your-api-token"
}
Logout
POST /api/logout
Request Body:
none
Response:
{
'message' => 'Successfully logged out.'
}
User
POST /api/user
Request Body:
Authorization: Bearer {your-access-token}
Accept: application/json
Response:
{
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"email_verified_at": "2023-11-09T10:00:00.000000Z",
"created_at": "2023-01-01T12:00:00.000000Z",
"updated_at": "2023-11-09T12:00:00.000000Z"
}
Error Handling
All errors follow a consistent format:
{
"success": false,
"message": "Invalid credentials",
"errors": {
"email": ["The email field is required."]
}
}