Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you from a bare checkout to a running local server where you can authenticate as a customer and hit your first protected endpoint. By the end you will have a JWT bearer token in hand and a successful response from GET /api/ecommerce/home.
1

Clone the repository and install PHP dependencies

Clone the project from GitHub and install all Composer packages. PHP 8.1 or higher and Composer 2 must already be installed on your machine.
git clone https://github.com/JuanSCaicedo/Api-Ecommerce.git
cd Api-Ecommerce
composer install
2

Configure environment variables

Copy the example environment file and open .env in your editor. At minimum set your MySQL credentials and generate the two required secret keys.
cp .env.example .env
Edit .env and update the database block:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=api_ecommerce
DB_USERNAME=root
DB_PASSWORD=your_password
Then generate the Laravel application key and the JWT secret:
php artisan key:generate
php artisan jwt:secret
php artisan jwt:secret writes a JWT_SECRET value directly into your .env file. Keep this value private — it signs every token the API issues.
3

Run database migrations and seeders

Create all tables and populate them with initial seed data (including any default admin account defined in the seeders).
php artisan migrate --seed
4

Start the development server

Boot the built-in Laravel development server on port 8000.
php artisan serve
The API is now available at http://127.0.0.1:8000. All route prefixes documented here are relative to that base URL.
5

Register a customer, verify email, and obtain a JWT token

First, register a new customer account. The registration endpoint is public and rate-limited to 10 requests per minute.
curl -s -X POST http://127.0.0.1:8000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane",
    "surname": "Doe",
    "phone": "3001234567",
    "email": "user@example.com",
    "password": "secret123"
  }'
The API sends a verification email containing a code_user value (stored as uniqd on the user). Verify the account before logging in:
curl -s -X POST http://127.0.0.1:8000/api/auth/verified_auth \
  -H "Content-Type: application/json" \
  -d '{"code_user": "<code_from_email>"}'
Now log in with the customer login endpoint:
curl -s -X POST http://127.0.0.1:8000/api/auth/login_ecommerce \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "secret123"}'
A successful login returns a token response:
{
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
  "token_type": "bearer",
  "expires_in": 3600,
  "user": {
    "full_name": "Jane Doe",
    "email": "user@example.com",
    "name": "Jane"
  }
}
Copy the access_token value. Now use it to call a protected storefront endpoint:
curl -s http://127.0.0.1:8000/api/ecommerce/home \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
You should receive the home feed JSON containing featured products, sliders, and categories.
The examples above use the customer login endpoint (/api/auth/login_ecommerce). If you need to authenticate as an administrator, use /api/auth/login instead — admin and customer tokens are issued through separate endpoints and are not interchangeable. See the Authentication guide for full details on both flows, token refresh, logout, and email verification.

Build docs developers (and LLMs) love