Skip to content

nduagoziem/laravel-ecommerce-api

Repository files navigation

GADGETS HUB E-COMMERCE API

A Demo API for a brand that deals on all kinds of gadgets. Built with the Laravel Framework.

Table of Contents

Installation and Setup

Clone the repository:

git clone https://github.com/nduagoziem/laravel-ecommerce-api
cd laravel-ecommerce-api

Install dependencies:

composer install
npm install

Set up environment variables:

Create a .env file in the root directory and add the necessary environment variables. Use .env.example as a guide.

Run the application:

php artisan migrate
php artisan serve
npm run dev

Authentication

Registration - Post Request

ENDPOINT
"/customer/register"

REQUEST

{
  "name": "John Doe",
  "email": "[email protected]",
  "password": "password123",
}

RESPONSE

{
  "success": true,
  "message": "Your account was created successfully."
}

STATUS
201

Login - Post Request

ENDPOINT
"/customer/login"

REQUEST

{
  "email": "[email protected]",
  "password": "password123",
}

RESPONSE

{
  "success": true,
  "message": "Login successful."
}

STATUS
200

Logged In Customer - Get Request

ENDPOINT
"/customer"

RESPONSE

{
  "success": true,
  "message": 
  [
    "name": "John Doe",
    "email": "[email protected]",
  ]
}

STATUS
200

Logout - Post Request

ENDPOINT
"/customer/logout"

REQUEST

RESPONSE

{
  "message": "Logged out."
}

STATUS
200

Cart

You must have an account and be logged in before using the cart feature.

Add to Cart - Post Request

ENDPOINT
"/cart/add"

REQUEST

{
  "name": "Brand New PS5 Gaming Setup",
  "imagePath": "https://yourimagepath.example.com",
  "productId": 247 // Primary key of the product in the DB. Of course this is sanitized and re-validated.
}

RESPONSE

{
  "success": true,
  "message": "Added to Cart."
}

STATUS
200

Show Cart - Get Request

ENDPOINT
"/cart/show"

RESPONSE

{
  "cart_id": 1,
  "created_at": "2025-09-24T10:27:44.000000Z",
  "id": 63,
  "image_path": "https://yourimagepath.example.com",
  "in_stock": 1,
  "name": "Digital HD Camera",
  "price": "20000.00",
  "product_id": 1,
  "quantity": 1,
  "updated_at": "2025-09-24T10:27:44.000000Z"
}

STATUS
200

Update Cart - Patch Request

ENDPOINT
"/cart/update"

REQUEST

{
  "name": "Digital HD Camera",
  "productId": 44,
  "quantity": 102,
}

Remove from cart - Post Request

ENDPOINT
"/cart/remove"

REQUEST

{
  "name": "Pink Headset",
  "productId": 6,
}

RESPONSE

{
  "success": true,
  "message": "Removed from cart."
}

STATUS
200

Estimated Total Price - Get Request

ENDPOINT
"/cart/total"

RESPONSE

{
  "message": 20000.00 // 20,0000
}

STATUS
200

Gadgets

  • Phones
  • Computers
  • Tablets
  • Other Accessories
  • Order

    Order and Pay - Post Request

    ENDPOINT
    "/customer/order"
    
    REQUEST
    
    {
      "first_name": "John", // Required
      "last_name": "Doe", // Required
      "email": "[email protected]", // Required
      "phone_number": "08023456789", // Required - Phone Number should be a string.
      "address": "42nd Japa Street.", // Required
      "country": "Nigeria", // Required
      "apartment_name": "", // Optional
      "state": "Oyo", // Required
      "postal_code": , // Optional
      "city": "My City", // Required
    }
    
    RESPONSE
    {
      "success": true,
      "message": "https://redirect-url-for-payment"
    }
    
    STATUS
    200

    About

    This project is still in development.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages