SHWID Marketplace [DEVELOPEMENT]

Introduction

This is the official documentation of the shwid marketplace api

This documentation aims to provide all the information you need to work with our API.

Authenticating requests

This API is not authenticated.

Authentication

Verify User.

POST
http://127.0.0.1:8000
/api/v1/verify-new-account

This endpoint validates the OTP code sent to the user's email and marks their account as verified.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/verify-new-account"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "otp": "123456",
    "user_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Send password reset link to user's email

POST
http://127.0.0.1:8000
/api/v1/password-email

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/password-email"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "user@example.com"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Password reset link sent successfully",
    "data": {
        "email": "user@example.com"
    }
}
{
    "status": false,
    "message": "User with this email address not found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "email": [
            "The email field is required",
            "The email must be a valid email address"
        ]
    }
}

Send OTP for password reset

POST
http://127.0.0.1:8000
/api/v1/password-otp

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/password-otp"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "user@example.com"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "OTP sent successfully",
    "data": {
        "email": "user@example.com",
        "expires_in": "5 minutes"
    }
}
{
    "status": false,
    "message": "User with this email address not found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "email": [
            "The email field is required",
            "The email must be a valid email address"
        ]
    }
}
{
    "status": false,
    "message": "Too many OTP requests. Please try again later."
}

Reset user password using token

POST
http://127.0.0.1:8000
/api/v1/password-reset

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/password-reset"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "user@example.com",
    "password": "newPassword123",
    "password_confirmation": "newPassword123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Password has been reset successfully",
    "data": {
        "email": "user@example.com"
    }
}
{
    "status": false,
    "message": "Invalid or expired password reset token"
}
{
    "status": false,
    "message": "User with this email address not found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "email": [
            "The email field is required",
            "The email must be a valid email address"
        ],
        "password": [
            "The password field is required",
            "The password must be at least 8 characters"
        ],
        "password_confirmation": [
            "The password confirmation does not match"
        ]
    }
}

Logs out the currently authenticated user by deleting all tokens

POST
http://127.0.0.1:8000
/api/v1/logout
requires authentication

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/logout"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
Example response:
{
    "message": "Logged out successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}

Get the authenticated user's profile details

GET
http://127.0.0.1:8000
/api/v1/get-profile
requires authentication

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/get-profile"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "data": {
        "id": 1,
        "name": "John Doe",
        "email": "john@example.com",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    },
    "message": "Authenticated users details fetched successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}

Authenticate user and generate access token

POST
http://127.0.0.1:8000
/api/v1/login

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/login"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "email": "user@example.com",
    "password": "password123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Authenticate user via Google Sign-In

POST
http://127.0.0.1:8000
/api/v1/login-with-google

Handles the authentication process for users signing in with Google credentials. Creates a new user account if the email doesn't exist, or updates existing Google ID.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/login-with-google"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "id": "\"114252345678912345678\"",
    "email": "\"user@example.com\"",
    "name": "\"John Doe\"",
    "familyName": "\"Doe\"",
    "givenName": "\"John\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Banner Management

POST
http://127.0.0.1:8000
/api/v1/banners

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "title": "\"Summer Sale\"",
    "slug": "\"summer-sale-2023\"",
    "description": "\"Special summer promotion banner\"",
    "image": "\"banner.jpg\"",
    "type": "\"home\"",
    "status": "\"active\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banner created successfully",
    "data": {
        "id": 1,
        "title": "Summer Sale",
        "slug": "summer-sale-2023",
        "description": "Special summer promotion banner",
        "image": "banners/summer-sale-2023.jpg",
        "type": "home",
        "status": "active",
        "created_at": "2023-07-20T12:00:00.000000Z",
        "updated_at": "2023-07-20T12:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "title": [
            "The title field is required"
        ],
        "image": [
            "The image field is required"
        ],
        "type": [
            "The type field is required"
        ]
    }
}
{
    "status": false,
    "message": "Failed to create banner",
    "error": "Internal server error"
}
GET
http://127.0.0.1:8000
/api/v1/banners

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banners retrieved successfully",
    "data": [
        {
            "id": 1,
            "title": "Summer Sale",
            "slug": "summer-sale-2023",
            "description": "Special summer promotion banner",
            "image": "banners/summer-sale-2023.jpg",
            "type": "home",
            "status": "active",
            "created_at": "2023-07-20T12:00:00.000000Z",
            "updated_at": "2023-07-20T12:00:00.000000Z"
        },
        {
            "id": 2,
            "title": "Winter Collection",
            "slug": "winter-collection-2023",
            "description": "Winter collection promotional banner",
            "image": "banners/winter-collection-2023.jpg",
            "type": "category",
            "status": "active",
            "created_at": "2023-07-20T12:00:00.000000Z",
            "updated_at": "2023-07-20T12:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "No banners found",
    "data": []
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}
GET
http://127.0.0.1:8000
/api/v1/banners/filter/{type}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

type
string
required

The type of banners to fetch.

Example:
home
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners/filter/home"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banners retrieved successfully",
    "data": [
        {
            "id": 1,
            "title": "Summer Sale",
            "slug": "summer-sale-2023",
            "description": "Special summer promotion banner",
            "image": "banners/summer-sale-2023.jpg",
            "type": "home",
            "status": "active",
            "created_at": "2023-07-20T12:00:00.000000Z",
            "updated_at": "2023-07-20T12:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "No banners found for the specified type",
    "data": []
}
{
    "status": false,
    "message": "Failed to retrieve banners",
    "error": "Internal server error"
}
GET
http://127.0.0.1:8000
/api/v1/banners/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the banner.

Example:
aut
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners/aut"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banner retrieved successfully",
    "data": {
        "id": 1,
        "title": "Summer Sale",
        "slug": "summer-sale-2023",
        "description": "Special summer promotion banner",
        "image": "banners/summer-sale-2023.jpg",
        "type": "home",
        "status": "active",
        "created_at": "2023-07-20T12:00:00.000000Z",
        "updated_at": "2023-07-20T12:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Banner not found",
    "error": "The requested banner could not be found"
}
{
    "status": false,
    "message": "Failed to retrieve banner",
    "error": "Internal server error"
}
POST
http://127.0.0.1:8000
/api/v1/banners/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the banner.

Example:
tempora

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners/tempora"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "title": "\"Updated Summer Sale\"",
    "slug": "\"updated-summer-sale-2023\"",
    "description": "\"Updated special summer promotion banner\"",
    "image": "\"updated-banner.jpg\"",
    "type": "\"home\"",
    "status": "\"active\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banner updated successfully",
    "data": {
        "id": 1,
        "title": "Updated Summer Sale",
        "slug": "updated-summer-sale-2023",
        "description": "Updated special summer promotion banner",
        "image": "banners/updated-summer-sale-2023.jpg",
        "type": "home",
        "status": "active",
        "created_at": "2023-07-20T12:00:00.000000Z",
        "updated_at": "2023-07-20T12:30:00.000000Z"
    }
}
{
    "status": false,
    "message": "Banner not found",
    "error": "The requested banner could not be found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "title": [
            "The title field is required"
        ],
        "image": [
            "The image field is required"
        ],
        "type": [
            "The type field is required"
        ]
    }
}
{
    "status": false,
    "message": "Failed to update banner",
    "error": "Internal server error"
}
DELETE
http://127.0.0.1:8000
/api/v1/banners/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the banner.

Example:
minima
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/banners/minima"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Banner deleted successfully"
}
{
    "status": false,
    "message": "Banner not found",
    "error": "The requested banner could not be found"
}
{
    "status": false,
    "message": "Failed to delete banner",
    "error": "Internal server error"
}

Brand Category Management

Create a new category

POST
http://127.0.0.1:8000
/api/v1/categories

Creates a new category with the provided details

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "Electronics",
    "slug": "electronics",
    "description": "Electronic devices and accessories"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Category created successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "description": "Electronic devices and accessories",
        "created_at": "2023-01-01T00:00:00Z",
        "updated_at": "2023-01-01T00:00:00Z"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "slug": [
            "The slug has already been taken"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Server error details"
}

Get all categories

GET
http://127.0.0.1:8000
/api/v1/categories

Lists all available categories in the system

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Categories retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Electronics",
            "slug": "electronics",
            "description": "Electronic devices and accessories",
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ]
}
{
    "status": false,
    "message": "No categories found",
    "data": []
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Server error details"
}

Get detailed information for a specific category by slug

GET
http://127.0.0.1:8000
/api/v1/categories/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique slug of the category.

Example:
electronics
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories/electronics"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Category retrieved successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "description": "Electronic devices and accessories",
        "image": "categories/electronics.jpg",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Category not found",
    "data": null
}
GET
http://127.0.0.1:8000
/api/v1/categories/filter/search

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories/filter/search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "electronics",
    "per_page": 10,
    "page": 1,
    "status": true
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Get categories filtered by brand

GET
http://127.0.0.1:8000
/api/v1/categories/filter/brand

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories/filter/brand"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "brand_id": 1,
    "status": true
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Categories retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Electronics",
            "slug": "electronics",
            "description": "Electronic products category",
            "image": "categories/electronics.jpg",
            "status": true,
            "brand_id": 1,
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "Brand not found",
    "data": []
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "brand_id": [
            "The brand id field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Server error details"
}

Update a specific category's information

POST
http://127.0.0.1:8000
/api/v1/categories/{slug}

Headers

Content-Type
Example:
multipart/form-data
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique slug of the category to update.

Example:
electronics

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories/electronics"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('name', 'Electronics & Gadgets');
body.append('description', 'All electronic devices and accessories');
body.append('status', '1');
body.append('image', document.querySelector('input[name="image"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Category updated successfully",
    "data": {
        "id": 1,
        "name": "Electronics & Gadgets",
        "slug": "electronics-gadgets",
        "description": "All electronic devices and accessories",
        "image": "categories/electronics-updated.jpg",
        "status": true,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Category not found",
    "data": null
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "image": [
            "The image must be a valid image file"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Server error details"
}

Delete a category by its slug

DELETE
http://127.0.0.1:8000
/api/v1/categories/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the category.

Example:
ut
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/categories/ut"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Category deleted successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "description": "Electronic products category",
        "image": "categories/electronics.jpg",
        "status": true,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Category not found",
    "data": null
}
{
    "status": false,
    "message": "Invalid slug format",
    "errors": {
        "slug": [
            "The slug must be a valid string"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Server error details"
}

Brand Management

Create a new brand

POST
http://127.0.0.1:8000
/api/v1/brands

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "\"Nike\"",
    "slug": "\"nike\"",
    "description": "\"Sports apparel and equipment manufacturer\"",
    "image": "\"brands\/nike-image.png\"",
    "status": true
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Brand created successfully",
    "data": {
        "id": 1,
        "name": "Nike",
        "slug": "nike",
        "description": "Sports apparel and equipment manufacturer",
        "image": "brands/nike-image.png",
        "status": true,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "slug": [
            "The slug field is required"
        ]
    }
}
{
    "status": false,
    "message": "An error occurred while creating the brand",
    "error": "Internal server error"
}

Get all brands

GET
http://127.0.0.1:8000
/api/v1/brands

Lists all available brands in the system with their details

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Brands retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Brand Name",
            "slug": "brand-name",
            "description": "Brand description",
            "image": "path/to/image.jpg",
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "No brands found",
    "data": []
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error details"
}

Get Single Brand Details

GET
http://127.0.0.1:8000
/api/v1/brands/{slug}

Retrieves detailed information for a specific brand using its slug

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the brand.

Example:
ut
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands/ut"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Brand retrieved successfully",
    "data": {
        "id": 1,
        "name": "Brand Name",
        "slug": "brand-name",
        "description": "Brand description",
        "image": "path/to/image.jpg",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Brand not found",
    "error": "The requested brand does not exist"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error details"
}
GET
http://127.0.0.1:8000
/api/v1/brands/filter/search

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands/filter/search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "nike",
    "status": true,
    "category_id": 1,
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Get brands filtered by category

GET
http://127.0.0.1:8000
/api/v1/brands/filter/category

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands/filter/category"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "category_id": 1,
    "per_page": 10,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Brands retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Brand Name",
            "slug": "brand-name",
            "description": "Brand description",
            "image": "path/to/image.jpg",
            "status": true,
            "category_id": 1,
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ],
    "pagination": {
        "total": 10,
        "per_page": 10,
        "current_page": 1,
        "last_page": 1
    }
}
{
    "status": false,
    "message": "No brands found for this category",
    "data": []
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "category_id": [
            "The category id field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error details"
}

Delete a brand by its slug

DELETE
http://127.0.0.1:8000
/api/v1/brands/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the brand to delete

Example:
sample-brand
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/brands/sample-brand"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Brand deleted successfully"
}
{
    "status": false,
    "message": "Brand not found"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error details"
}

Customer Management

Create a new customer account

POST
http://127.0.0.1:8000
/api/v1/customers
requires authentication

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@example.com",
    "phone": "+1234567890",
    "password": "password123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Customer account created successfully",
    "data": {
        "id": 1,
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com",
        "phone": "+1234567890",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "zip_code": "10001",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "success": false,
    "error": "Specific error message here",
    "message": "sorry unable to create account"
}
{
    "success" false,
    "message": "Customer with this email already exists"
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "email": [
            "The email field is required.",
            "The email must be a valid email address."
        ],
        "first_name": [
            "The first name field is required."
        ],
        "last_name": [
            "The last name field is required."
        ],
        "phone": [
            "The phone field is required."
        ]
    }
}

Get all customers

GET
http://127.0.0.1:8000
/api/v1/customers
requires authentication

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "data": [
        {
            "id": 1,
            "email": "customer@example.com",
            "role": "customer",
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ],
    "message": "All users fetched successfully",
    "success": true,
    "links": {
        "first": "http://example.com/api/customers?page=1",
        "last": "http://example.com/api/customers?page=5",
        "prev": null,
        "next": "http://example.com/api/customers?page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 5,
        "path": "http://example.com/api/customers",
        "per_page": 20,
        "to": 20,
        "total": 100
    }
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to access this resource",
    "success": false
}

Get a customer by ID

GET
http://127.0.0.1:8000
/api/v1/customers/{slug}
requires authentication

Get detailed information about a specific customer

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique slug identifier of the customer.

Example:
14
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/14"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "data": {
        "id": 1,
        "slug": "customer-123",
        "email": "customer@example.com",
        "name": "John Doe",
        "role": "customer",
        "status": "active",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    },
    "message": "Customer details fetched successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to view this customer",
    "success": false
}
{
    "message": "Customer not found",
    "success": false
}

Get customers with top deals

GET
http://127.0.0.1:8000
/api/v1/customers/filter/top-deals
requires authentication

Retrieves a list of customers who have made significant purchases or have high-value deals

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/filter/top-deals"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "product_count": 5,
    "count": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "data": [
        {
            "id": 1,
            "name": "John Doe",
            "email": "john@example.com",
            "total_deals_amount": 50000,
            "deals_count": 5,
            "latest_deal_date": "2023-12-01T10:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    },
    "message": "Top customers retrieved successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to view top customers",
    "success": false
}

Get Customers By Status

GET
http://127.0.0.1:8000
/api/v1/customers/filter/status
requires authentication

Retrieves a filtered list of customers based on their account status

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/filter/status"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "ACTIVE"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "data": [
        {
            "id": 1,
            "name": "John Doe",
            "email": "john@example.com",
            "status": "active",
            "created_at": "2023-12-01T10:00:00.000000Z",
            "updated_at": "2023-12-01T10:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    },
    "message": "Customers retrieved successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to view customers",
    "success": false
}
{
    "message": "The status field is required",
    "errors": {
        "status": [
            "The status field is required"
        ]
    },
    "success": false
}
GET
http://127.0.0.1:8000
/api/v1/customers/filter/search

Search for customers based on provided criteria

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/filter/search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "john",
    "status": "active",
    "sort": "name",
    "order": "asc",
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Get Customers Who Buy From Me

GET
http://127.0.0.1:8000
/api/v1/customers/filter/my-customers

Get a list of customers who have made purchases from the authenticated seller

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/filter/my-customers"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "page": 1,
    "per_page": 10,
    "search": "john",
    "date_from": "2023-01-01",
    "date_to": "2023-12-31"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "data": [
        {
            "id": 1,
            "name": "John Doe",
            "email": "john@example.com",
            "total_purchases": 1500,
            "last_purchase_date": "2023-12-01T10:00:00.000000Z",
            "created_at": "2023-12-01T10:00:00.000000Z",
            "updated_at": "2023-12-01T10:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    },
    "message": "Customers retrieved successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to view customer purchase history",
    "success": false
}
{
    "message": "Invalid date format",
    "errors": {
        "date_from": [
            "The date from must be a valid date format Y-m-d"
        ],
        "date_to": [
            "The date to must be a valid date format Y-m-d"
        ]
    },
    "success": false
}

Customer Password Change

POST
http://127.0.0.1:8000
/api/v1/change-password

Change customer account password

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/change-password"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "current_password": "oldPassword123",
    "new_password": "newPassword123",
    "new_password_confirmation": "newPassword123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Password changed successfully",
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to change this password",
    "success": false
}
{
    "message": "The given data was invalid",
    "errors": {
        "current_password": [
            "The current password is incorrect"
        ],
        "new_password": [
            "The password must be at least 8 characters",
            "The password confirmation does not match"
        ]
    },
    "success": false
}

Update Customer Profile

PATCH
http://127.0.0.1:8000
/api/v1/update-customers

Updates the authenticated customer's profile information

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/update-customers"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@example.com",
    "phone": "+1234567890",
    "address": "123 Main St",
    "city": "New York",
    "state": "NY",
    "country": "USA",
    "zip_code": "10001"
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Profile updated successfully",
    "data": {
        "id": 1,
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com",
        "phone": "+1234567890",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "country": "USA",
        "zip_code": "10001",
        "updated_at": "2023-12-20T12:00:00.000000Z"
    },
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to update this profile",
    "success": false
}
{
    "message": "The given data was invalid",
    "errors": {
        "email": [
            "The email has already been taken"
        ],
        "phone": [
            "The phone number format is invalid"
        ],
        "first_name": [
            "The first name field is required"
        ]
    },
    "success": false
}

Toggle customer chat status

PATCH
http://127.0.0.1:8000
/api/v1/toggle-chat-status

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/toggle-chat-status"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": true
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Chat status updated successfully",
    "data": {
        "chat_status": true,
        "updated_at": "2023-12-20T12:00:00.000000Z"
    },
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to update chat status",
    "success": false
}
{
    "message": "The given data was invalid",
    "errors": {
        "status": [
            "The status field is required",
            "The status field must be true or false"
        ]
    },
    "success": false
}

Delete customer account

PATCH
http://127.0.0.1:8000
/api/v1/delete-account

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/delete-account"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "PATCH",
    headers,
}).then(response => response.json());
Example response:

Update customer account status

PATCH
http://127.0.0.1:8000
/api/v1/customers/update-customers-status/{user_id}

Update customer account status with reason

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

user_id
string
required

The ID of the user.

Example:
et

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/customers/update-customers-status/et"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "active",
    "reason": "Account verified"
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Account status updated successfully",
    "success": true,
    "data": {
        "user_id": 1,
        "status": "active",
        "updated_at": "2023-12-20T10:00:00Z"
    }
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "You do not have permission to update account status",
    "success": false
}
{
    "message": "Customer not found",
    "success": false
}
{
    "message": "The given data was invalid",
    "success": false,
    "errors": {
        "status": [
            "The status field is required"
        ]
    }
}
{
    "message": "Failed to update account status",
    "success": false
}

Add Billing Address

POST
http://127.0.0.1:8000
/api/v1/add-customers-address

Adds or updates a billing address for the authenticated customer

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/add-customers-address"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "address_line_1": "123 Main Street",
    "address_line_2": "Apt 4B",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "United States"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Billing address added successfully",
    "data": {
        "address_line_1": "123 Main Street",
        "address_line_2": "Apt 4B",
        "city": "New York",
        "state": "NY",
        "postal_code": "10001",
        "country": "United States"
    },
    "success": true
}
{
    "message": "Unauthenticated",
    "success": false
}
{
    "message": "The given data was invalid",
    "errors": {
        "address_line_1": [
            "The address line 1 field is required"
        ],
        "city": [
            "The city field is required"
        ],
        "state": [
            "The state field is required"
        ],
        "postal_code": [
            "The postal code field is required"
        ],
        "country": [
            "The country field is required"
        ]
    },
    "success": false
}

Feedback Management

Create a new feedback entry

POST
http://127.0.0.1:8000
/api/v1/feedbacks

Store a new feedback entry in the database

Headers

Content-Type
Example:
multipart/form-data
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/feedbacks"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('type', '"bug"');
body.append('title', '"App crashes on startup"');
body.append('description', '"When opening the app, it crashes immediately after splash screen"');
body.append('user_id', '1');
body.append('status', '"pending"');
body.append('attachments[]', document.querySelector('input[name="attachments[]"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Feedback created successfully",
    "data": {
        "id": 1,
        "type": "bug",
        "title": "App crashes on startup",
        "description": "When opening the app, it crashes immediately after splash screen",
        "user_id": 1,
        "status": "pending",
        "created_at": "2023-12-20T10:00:00.000000Z",
        "updated_at": "2023-12-20T10:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "type": [
            "The type field is required"
        ],
        "title": [
            "The title field is required"
        ],
        "description": [
            "The description field is required"
        ],
        "user_id": [
            "The user id field is required"
        ]
    }
}
{
    "status": false,
    "message": "An error occurred while creating feedback",
    "error": "Internal server error"
}

Get a list of all feedbacks

GET
http://127.0.0.1:8000
/api/v1/feedbacks

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

The page number for pagination.

Example:
1
per_page
integer

The number of items per page.

Example:
10
search
string

Search term to filter feedbacks.

Example:
"bug"
sort
string

Field to sort by (created_at, title, type).

Example:
"created_at"
order
string

Sort order (asc, desc).

Example:
"desc"
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/feedbacks"
);

const params = {
    "page": "1",
    "per_page": "10",
    "search": ""bug"",
    "sort": ""created_at"",
    "order": ""desc"",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Feedbacks retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "type": "bug",
                "title": "App crashes on startup",
                "description": "When opening the app, it crashes immediately after splash screen",
                "user_id": 1,
                "status": "pending",
                "created_at": "2023-12-20T10:00:00.000000Z",
                "updated_at": "2023-12-20T10:00:00.000000Z"
            }
        ],
        "total": 50,
        "per_page": 10,
        "last_page": 5
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "User not authenticated"
}
{
    "status": false,
    "message": "An error occurred while retrieving feedbacks",
    "error": "Internal server error"
}

Get feedbacks filtered by type

GET
http://127.0.0.1:8000
/api/v1/feedbacks/filter/type

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

The page number for pagination.

Example:
1
per_page
integer

The number of items per page.

Example:
10
type
string
required

The type of feedback to filter by.

Example:
"bug"
sort
string

Field to sort by (created_at, title).

Example:
"created_at"
order
string

Sort order (asc, desc).

Example:
"desc"
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/feedbacks/filter/type"
);

const params = {
    "page": "1",
    "per_page": "10",
    "type": ""bug"",
    "sort": ""created_at"",
    "order": ""desc"",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Feedbacks retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "type": "bug",
                "title": "App crashes on startup",
                "description": "When opening the app, it crashes immediately",
                "user_id": 1,
                "status": "pending",
                "created_at": "2023-12-20T10:00:00.000000Z",
                "updated_at": "2023-12-20T10:00:00.000000Z"
            }
        ],
        "total": 20,
        "per_page": 10,
        "last_page": 2
    }
}
{
    "status": false,
    "message": "No feedbacks found for the specified type",
    "data": []
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "type": [
            "The type field is required."
        ]
    }
}
{
    "status": false,
    "message": "An error occurred while retrieving feedbacks",
    "error": "Internal server error"
}

Location Data

Get a list of all states in the system

GET
http://127.0.0.1:8000
/api/v1/states

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Response Fields

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/states"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "States retrieved successfully",
    "data": {
        "states": [
            {
                "id": 1,
                "name": "Lagos"
            },
            {
                "id": 2,
                "name": "Abuja"
            }
        ]
    }
}
{
    "status": false,
    "message": "An error occurred while fetching states",
    "error": "Internal server error"
}

Get a list of Local Government Areas (LGAs) for a specific state

GET
http://127.0.0.1:8000
/api/v1/lgas/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the state to fetch LGAs for.

Example:
1
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/lgas/1"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "LGAs retrieved successfully",
    "data": {
        "lgas": [
            {
                "id": 1,
                "name": "Alimosho",
                "state_id": 1
            },
            {
                "id": 2,
                "name": "Ikeja",
                "state_id": 1
            }
        ]
    }
}
{
    "status": false,
    "message": "State not found",
    "error": "The specified state ID does not exist"
}
{
    "status": false,
    "message": "An error occurred while fetching LGAs",
    "error": "Internal server error"
}

Orders Management

Get order history for the authenticated user.

GET
http://127.0.0.1:8000
/api/v1/orders

This endpoint retrieves a paginated list of orders with their associated relationships including shipping address, customer details, and product information.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

Page number for pagination.

Example:
1
per_page
integer

Number of items per page.

Example:
10
sort
string

Sort orders by field (created_at, order_no).

Example:
created_at
order
string

Sort direction (asc, desc).

Example:
desc
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders"
);

const params = {
    "page": "1",
    "per_page": "10",
    "sort": "created_at",
    "order": "desc",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Orders retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "order_no": "ORD-20220101-1",
                "status": "completed",
                "created_at": "2022-01-01T00:00:00.000000Z",
                "updated_at": "2022-01-01T00:00:00.000000Z",
                "relationships": {
                    "shipping_address": {
                        "id": 1,
                        "address": "123 Main St",
                        "city": "Anytown",
                        "state": "CA",
                        "zip": "12345"
                    },
                    "customer": {
                        "id": 1,
                        "name": "John Doe",
                        "email": "johndoe@example.com"
                    },
                    "product": {
                        "id": 1,
                        "name": "Product 1",
                        "price": 10
                    }
                }
            }
        ],
        "total": 10,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "Unauthenticated",
    "data": null
}
{
    "status": "error",
    "message": "You do not have permission to view orders",
    "data": null
}

Create a new order.

POST
http://127.0.0.1:8000
/api/v1/orders

This endpoint allows users to create a new order by specifying the product and quantity.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "product": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "message": "Order created successfully",
    "success": true,
    "data": {
        "id": 1,
        "order_no": "ORD-20220101-1",
        "status": "pending",
        "relationships": {
            "shipping_address": {
                "id": 1,
                "address": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zip": "12345",
                "country": "USA",
                "created_at": "2022-01-01T00:00:00.000000Z",
                "updated_at": "2022-01-01T00:00:00.000000Z",
                "deleted_at": null
            },
            "customer": {
                "id": 1,
                "name": "John Doe",
                "email": "johndoe@example.com",
                "phone": "555-555-5555",
                "created_at": "2022-01-01T00:00:00.000000Z",
                "updated_at": "2022-01-01T00:00:00.000000Z",
                "deleted_at": null
            },
            "product": {
                "id": 1,
                "name": "Product 1",
                "description": "This is product 1",
                "price": 10,
                "created_at": "2022-01-01T00:00:00.000000Z",
                "updated_at": "2022-01-01T00:00:00.000000Z",
                "deleted_at": null
            }
        },
        "created_at": "2022-01-01T00:00:00.000000Z",
        "updated_at": "2022-01-01T00:00:00.000000Z",
        "deleted_at": null
    }
}

Get Single Order Details

GET
http://127.0.0.1:8000
/api/v1/orders/{id}

Retrieves detailed information for a specific order by its ID, including relationships like shipping address, customer details, and product information.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
integer
required

The ID of the order.

Example:
1
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/1"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Order retrieved successfully",
    "data": {
        "id": 1,
        "order_no": "ORD-20220101-1",
        "status": "pending",
        "relationships": {
            "shipping_address": {
                "id": 1,
                "address": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zip": "12345",
                "country": "USA"
            },
            "customer": {
                "id": 1,
                "name": "John Doe",
                "email": "johndoe@example.com",
                "phone": "555-555-5555"
            },
            "product": {
                "id": 1,
                "name": "Product 1",
                "description": "This is product 1",
                "price": 10
            }
        },
        "created_at": "2022-01-01T00:00:00.000000Z",
        "updated_at": "2022-01-01T00:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "An error occurred while retrieving the order",
    "data": null
}

Update an existing order

PATCH
http://127.0.0.1:8000
/api/v1/orders/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the order.

Example:
commodi

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/commodi"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "completed",
    "quantity": "100",
    "price": "50.00"
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Order updated successfully",
    "data": {
        "id": 1,
        "status": "completed",
        "quantity": 100,
        "price": 50,
        "total": 5000,
        "created_at": "2023-01-01T12:00:00.000000Z",
        "updated_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "You are not authorized to update this order",
    "data": null
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "status": [
            "The status field must be a valid order status"
        ],
        "quantity": [
            "The quantity must be a positive number"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while updating the order",
    "data": null
}

Delete a specific order.

DELETE
http://127.0.0.1:8000
/api/v1/orders/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the order.

Example:
deleniti
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/deleniti"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Order deleted successfully",
    "data": null
}
{
    "success": false,
    "message": "You are not authorized to delete this order",
    "data": null
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Order cannot be deleted in its current state",
    "data": null
}
{
    "success": false,
    "message": "An error occurred while deleting the order",
    "data": null
}

Cancel a specific order.

DELETE
http://127.0.0.1:8000
/api/v1/orders/cancel-order/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the cancel order.

Example:
tempore
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/cancel-order/tempore"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Order cancelled successfully",
    "data": {
        "id": 1,
        "status": "cancelled",
        "cancelled_at": "2023-01-01T12:00:00.000000Z",
        "updated_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "You are not authorized to cancel this order",
    "data": null
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Order cannot be cancelled in its current state",
    "data": null
}
{
    "success": false,
    "message": "An error occurred while cancelling the order",
    "data": null
}

Filter Orders By Date Range

GET
http://127.0.0.1:8000
/api/v1/orders/filter/date

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/filter/date"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "start_date": "2023-01-01",
    "end_date": "2023-12-31"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Orders filtered successfully",
    "data": [
        {
            "id": 1,
            "order_no": "ORD-20230101-1",
            "status": "completed",
            "created_at": "2023-01-01T10:00:00.000000Z",
            "updated_at": "2023-01-01T10:00:00.000000Z"
        }
    ],
    "meta": {
        "total": 1,
        "per_page": 15,
        "current_page": 1,
        "last_page": 1
    }
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "start_date": [
            "The start date field is required",
            "The start date must be a valid date"
        ],
        "end_date": [
            "The end date field is required",
            "The end date must be a valid date"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while filtering orders",
    "data": null
}

Filter orders by their current status

GET
http://127.0.0.1:8000
/api/v1/orders/filter/status

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/filter/status"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "pending"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Orders filtered successfully",
    "data": [
        {
            "id": 1,
            "order_no": "ORD-20230101-1",
            "status": "pending",
            "customer_name": "John Doe",
            "total_amount": 150,
            "created_at": "2023-01-01T10:00:00.000000Z",
            "updated_at": "2023-01-01T10:00:00.000000Z"
        }
    ],
    "meta": {
        "total": 1,
        "per_page": 15,
        "current_page": 1,
        "last_page": 1
    }
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "status": [
            "The status field is required",
            "The status must be a valid order status"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while filtering orders",
    "data": null
}

Get orders for a specific customer based on provided filters

GET
http://127.0.0.1:8000
/api/v1/orders/filter/customer

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/filter/customer"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "customer_id": 1,
    "status": "pending",
    "from_date": "2023-01-01",
    "to_date": "2023-12-31",
    "sort": "created_at",
    "order": "desc"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Orders retrieved successfully",
    "data": {
        "orders": [
            {
                "id": 1,
                "customer_id": 1,
                "order_number": "ORD-2023-001",
                "status": "pending",
                "total_amount": 150,
                "created_at": "2023-01-01T12:00:00.000000Z",
                "updated_at": "2023-01-01T12:00:00.000000Z"
            }
        ],
        "total": 1,
        "page": 1,
        "per_page": 10
    }
}
{
    "success": false,
    "message": "You are not authorized to view these orders",
    "data": null
}
{
    "success": false,
    "message": "Customer not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "customer_id": [
            "The customer id field is required"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while retrieving orders",
    "data": null
}

Get trade history filtered by type

GET
http://127.0.0.1:8000
/api/v1/orders/filter/type

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/filter/type"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "type": "buy",
    "start_date": "2023-01-01",
    "end_date": "2023-12-31",
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Trade history retrieved successfully",
    "data": {
        "trades": [
            {
                "id": 1,
                "type": "buy",
                "amount": 100,
                "price": 50,
                "total": 5000,
                "created_at": "2023-01-01T12:00:00.000000Z",
                "updated_at": "2023-01-01T12:00:00.000000Z"
            }
        ],
        "total": 1,
        "page": 1,
        "per_page": 10
    }
}
{
    "success": false,
    "message": "No trade history found for the specified type",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "type": [
            "The type field is required"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while retrieving trade history",
    "data": null
}

Get available couriers for a specific order based on location and criteria.

GET
http://127.0.0.1:8000
/api/v1/orders/couriers/fetch

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/couriers/fetch"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_id": 1,
    "radius": 5,
    "max_couriers": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Available couriers retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "John Smith",
            "phone": "+1234567890",
            "current_location": {
                "latitude": 40.7128,
                "longitude": -74.006
            },
            "distance": 2.5,
            "rating": 4.8,
            "available": true
        }
    ],
    "meta": {
        "total_couriers": 1,
        "search_radius": 5
    }
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "order_id": [
            "The order ID field is required",
            "The order ID must be a valid order"
        ],
        "radius": [
            "The radius must be a positive number"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while retrieving available couriers",
    "data": null
}

Alert available couriers about a new order.

GET
http://127.0.0.1:8000
/api/v1/orders/couriers/alert

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/couriers/alert"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_id": 1,
    "radius": 5
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Couriers alerted successfully",
    "data": {
        "notified_couriers": 5,
        "order_id": 1,
        "notification_timestamp": "2023-01-01T10:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "order_id": [
            "The order ID field is required",
            "The order ID must be a valid order"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while alerting couriers",
    "data": null
}

Create a new shipment request for an order.

POST
http://127.0.0.1:8000
/api/v1/orders/couriers/request

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/couriers/request"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_id": 1,
    "pickup_address": "123 Main St",
    "delivery_address": "456 Oak Ave",
    "notes": "Handle with care"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Shipment request created successfully",
    "data": {
        "shipment_id": 1,
        "order_id": 1,
        "status": "pending",
        "pickup_address": "123 Main St",
        "delivery_address": "456 Oak Ave",
        "created_at": "2023-01-01T10:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "Order not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "order_id": [
            "The order ID field is required"
        ],
        "pickup_address": [
            "The pickup address field is required"
        ],
        "delivery_address": [
            "The delivery address field is required"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while creating the shipment request",
    "data": null
}

Accept a shipment applicant for an order

GET
http://127.0.0.1:8000
/api/v1/orders/couriers/accept

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/orders/couriers/accept"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "applicant_id": 1,
    "order_id": 100,
    "notes": "Verified credentials"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "success": true,
    "message": "Shipment applicant accepted successfully",
    "data": {
        "order_id": 100,
        "applicant_id": 1,
        "status": "accepted",
        "updated_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "success": false,
    "message": "You are not authorized to accept this applicant",
    "data": null
}
{
    "success": false,
    "message": "Applicant or order not found",
    "data": null
}
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "applicant_id": [
            "The applicant ID field is required"
        ],
        "order_id": [
            "The order ID field is required"
        ]
    }
}
{
    "success": false,
    "message": "An error occurred while accepting the shipment applicant",
    "data": null
}

Products Management

Create a new product

POST
http://127.0.0.1:8000
/api/v1/products

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "\"iPhone 13\"",
    "description": "\"Latest iPhone model\"",
    "price": "999.99",
    "category_id": 1,
    "images": [
        "image1.jpg",
        "image2.jpg"
    ],
    "status": "\"active\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product created successfully",
    "data": {
        "id": 1,
        "name": "iPhone 13",
        "slug": "iphone-13",
        "description": "Latest iPhone model",
        "price": 999.99,
        "category_id": 1,
        "status": "active",
        "images": [
            "image1.jpg",
            "image2.jpg"
        ],
        "created_at": "2023-01-15T00:00:00Z",
        "updated_at": "2023-01-15T00:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "price": [
            "The price must be a number"
        ],
        "category_id": [
            "The selected category id is invalid"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

Get all products

GET
http://127.0.0.1:8000
/api/v1/products

Returns a paginated list of all available products in the system

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

Page number for pagination.

Example:
1
per_page
integer

Number of items per page.

Example:
10
sort
string

Sort field (e.g. 'created_at', 'price').

Example:
created_at
order
string

Sort order ('asc' or 'desc').

Example:
desc
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products"
);

const params = {
    "page": "1",
    "per_page": "10",
    "sort": "created_at",
    "order": "desc",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "name": "Product Name",
                "description": "Product Description",
                "price": 99.99,
                "created_at": "2023-01-01T00:00:00Z",
                "updated_at": "2023-01-01T00:00:00Z"
            }
        ],
        "first_page_url": "http://example.com/api/products?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http://example.com/api/products?page=1",
        "links": [],
        "next_page_url": null,
        "path": "http://example.com/api/products",
        "per_page": 10,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get similar products

GET
http://127.0.0.1:8000
/api/v1/products/similar/{slug}

Get similar products based on the provided product slug

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the product to find similar items for.

Example:
blue-t-shirt
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/similar/blue-t-shirt"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Similar products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Similar Product 1",
            "slug": "similar-product-1",
            "description": "Product Description",
            "price": 99.99,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ]
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "slug": [
            "The specified product could not be found"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get Latest Products

GET
http://127.0.0.1:8000
/api/v1/products/filter/latest

Retrieves a paginated list of the most recently added products. Products can be filtered and sorted based on request parameters.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/latest"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "page": 1,
    "per_page": 10,
    "sort_by": "created_at",
    "sort_direction": "desc"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Latest products retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "name": "Product Name",
                "slug": "product-name",
                "description": "Product description",
                "price": 99.99,
                "created_at": "2023-01-01T00:00:00Z",
                "updated_at": "2023-01-01T00:00:00Z"
            }
        ],
        "first_page_url": "http://example.com/api/products/latest?page=1",
        "from": 1,
        "last_page": 5,
        "last_page_url": "http://example.com/api/products/latest?page=5",
        "next_page_url": "http://example.com/api/products/latest?page=2",
        "path": "http://example.com/api/products/latest",
        "per_page": 10,
        "prev_page_url": null,
        "to": 10,
        "total": 50
    }
}
{
    "status": "error",
    "message": "Invalid request parameters",
    "errors": {
        "sort_by": [
            "The sort_by field must be one of: created_at, price, name"
        ],
        "sort_direction": [
            "The sort_direction field must be one of: asc, desc"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get the latest products filtered by category

GET
http://127.0.0.1:8000
/api/v1/products/filter/category

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/category"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "category_id": 1,
    "per_page": 10,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Latest products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "category_id": 1,
            "description": "Product description",
            "price": 99.99,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "Category not found",
    "errors": {
        "category_id": [
            "The specified category does not exist"
        ]
    }
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "category_id": [
            "The category id field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get products by customer

GET
http://127.0.0.1:8000
/api/v1/products/filter/seller

Retrieves a paginated list of products associated with a specific customer based on the provided request parameters.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/seller"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "customer_id": 1,
    "per_page": 10,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "customer_id": 1,
            "category_id": 1,
            "description": "Product description",
            "price": 99.99,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "Customer not found",
    "errors": {
        "customer_id": [
            "The specified customer does not exist"
        ]
    }
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "customer_id": [
            "The customer id field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get all use products

GET
http://127.0.0.1:8000
/api/v1/my-products
requires authentication

Get all products belonging to the authenticated user

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

Page number for pagination.

Example:
1
per_page
integer

Number of items per page.

Example:
10
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/my-products"
);

const params = {
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "My products retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "name": "Product Name",
                "description": "Product Description",
                "price": 99.99,
                "created_at": "2023-01-01T00:00:00Z",
                "updated_at": "2023-01-01T00:00:00Z"
            }
        ],
        "first_page_url": "http://example.com/api/my-products?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http://example.com/api/my-products?page=1",
        "links": [],
        "next_page_url": null,
        "path": "http://example.com/api/my-products",
        "per_page": 10,
        "prev_page_url": null,
        "to": 1,
        "total": 1
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": "error",
    "message": "No products found",
    "data": []
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Get products filtered by status for the authenticated user

GET
http://127.0.0.1:8000
/api/v1/my-products/filter/status/{status}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

status
string
required

The status.

Example:
aut
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/my-products/filter/status/aut"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "description": "Product Description",
            "status": "active",
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ],
    "meta": {
        "total": 1
    }
}
{
    "status": "error",
    "message": "Unauthenticated",
    "errors": {
        "message": "User must be logged in to access their products"
    }
}
{
    "status": "error",
    "message": "Invalid status provided",
    "errors": {
        "status": [
            "The selected status is invalid"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}
GET
http://127.0.0.1:8000
/api/v1/my-products/filter/search

Search for user's products using simple search criteria

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/my-products/filter/search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "\"phone\"",
    "sort": "\"desc\"",
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Retrieve user products filtered by date range

GET
http://127.0.0.1:8000
/api/v1/my-products/filter/date

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/my-products/filter/date"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "start_date": "2023-01-01",
    "end_date": "2023-12-31"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "description": "Product Description",
            "price": 99.99,
            "user_id": 1,
            "created_at": "2023-01-15T00:00:00Z",
            "updated_at": "2023-01-15T00:00:00Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 1,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Invalid date parameters",
    "errors": {
        "start_date": [
            "The start date field is required"
        ],
        "end_date": [
            "The end date field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

End a product listing by changing its status to inactive

PATCH
http://127.0.0.1:8000
/api/v1/my-products/end/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the end.

Example:
laudantium
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/my-products/end/laudantium"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "PATCH",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product listing ended successfully",
    "data": {
        "id": 1,
        "slug": "product-slug",
        "status": "inactive",
        "updated_at": "2024-01-15T12:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "message": "The requested product could not be found"
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

Product info Get detailed information about a specific product

GET
http://127.0.0.1:8000
/api/v1/products/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique slug of the product.

Example:
iphone-13
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/iphone-13"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product retrieved successfully",
    "data": {
        "id": 1,
        "name": "iPhone 13",
        "slug": "iphone-13",
        "description": "Latest iPhone model",
        "price": 999.99,
        "category_id": 1,
        "status": "active",
        "images": [
            "image1.jpg",
            "image2.jpg"
        ],
        "created_at": "2023-01-15T00:00:00Z",
        "updated_at": "2023-01-15T00:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "message": "The requested product could not be found"
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

Update product details

POST
http://127.0.0.1:8000
/api/v1/products/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the product.

Example:
placeat

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/placeat"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "iPhone 13 Pro",
    "description": "Latest iPhone model with advanced features",
    "price": "999.99",
    "category_id": 1,
    "status": "active",
    "images": [
        "image1.jpg",
        "image2.jpg"
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product updated successfully",
    "data": {
        "id": 1,
        "name": "iPhone 13 Pro",
        "slug": "iphone-13-pro",
        "description": "Latest iPhone model with advanced features",
        "price": 999.99,
        "category_id": 1,
        "status": "active",
        "images": [
            "image1.jpg",
            "image2.jpg"
        ],
        "updated_at": "2023-01-15T00:00:00Z",
        "created_at": "2023-01-15T00:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "message": "The requested product could not be found"
    }
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "price": [
            "The price must be a number"
        ],
        "category_id": [
            "The category id field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

Delete a product permanently from the system

DELETE
http://127.0.0.1:8000
/api/v1/products/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the product.

Example:
dolores
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/dolores"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product deleted successfully",
    "data": {
        "slug": "product-slug",
        "deleted_at": "2024-01-15T12:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Forbidden action",
    "errors": {
        "message": "You do not have permission to delete this product"
    }
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "message": "The requested product could not be found"
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}
GET
http://127.0.0.1:8000
/api/v1/products/filter/search

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "\"laptop\"",
    "category": "\"electronics\"",
    "min_price": "100",
    "max_price": "1000",
    "sort": "\"desc\"",
    "limit": 10,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Get products filtered by their status

GET
http://127.0.0.1:8000
/api/v1/products/filter/status

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/status"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "active",
    "page": 1,
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "status": "active",
            "category_id": 1,
            "description": "Product description",
            "price": 99.99,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 10,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "No products found with the specified status",
    "data": []
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "status": [
            "The status field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred"
    }
}

Retrieve products filtered by date range

GET
http://127.0.0.1:8000
/api/v1/products/filter/date

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/date"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "start_date": "2023-01-01",
    "end_date": "2023-12-31",
    "per_page": 18,
    "page": 5
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Products retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Product Name",
            "description": "Product Description",
            "price": 99.99,
            "created_at": "2023-01-15T00:00:00Z",
            "updated_at": "2023-01-15T00:00:00Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "total": 1,
        "per_page": 10
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Invalid date parameters",
    "errors": {
        "start_date": [
            "The start date field is required"
        ],
        "end_date": [
            "The end date field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}
GET
http://127.0.0.1:8000
/api/v1/products/filter/simple-search

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/filter/simple-search"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "\"phone\"",
    "limit": 10,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:

Update the listing status of a product

PATCH
http://127.0.0.1:8000
/api/v1/products/update-status/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the update status.

Example:
unde

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/products/update-status/unde"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "active",
    "reason": "Product back in stock"
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": "success",
    "message": "Product listing status updated successfully",
    "data": {
        "id": 1,
        "slug": "iphone-13",
        "status": "active",
        "updated_at": "2023-01-15T00:00:00Z"
    }
}
{
    "status": "error",
    "message": "Unauthorized access",
    "errors": {
        "message": "User not authenticated"
    }
}
{
    "status": "error",
    "message": "Product not found",
    "errors": {
        "message": "The requested product could not be found"
    }
}
{
    "status": "error",
    "message": "Validation failed",
    "errors": {
        "status": [
            "The status field is required"
        ]
    }
}
{
    "status": "error",
    "message": "Internal server error",
    "errors": {
        "message": "An unexpected error occurred while processing your request"
    }
}

Saved Items Management

Get all saved items for the authenticated user

GET
http://127.0.0.1:8000
/api/v1/saved-items

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/saved-items"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Saved items retrieved successfully",
    "data": [
        {
            "id": 1,
            "item_id": 1,
            "type": "product",
            "user_id": 1,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z",
            "item": {
                "id": 1,
                "name": "Sample Item",
                "description": "Item description"
            }
        }
    ]
}
{
    "status": false,
    "message": "Unauthenticated"
}
{
    "status": false,
    "message": "No saved items found"
}

Get saved items filtered by type for the authenticated user

GET
http://127.0.0.1:8000
/api/v1/saved-items/filter

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/saved-items/filter"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "type": "product"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Saved items retrieved successfully",
    "data": [
        {
            "id": 1,
            "item_id": 1,
            "type": "product",
            "user_id": 1,
            "created_at": "2023-01-01T00:00:00Z",
            "updated_at": "2023-01-01T00:00:00Z",
            "item": {
                "id": 1,
                "name": "Sample Item",
                "description": "Item description"
            }
        }
    ]
}
{
    "status": false,
    "message": "Unauthenticated"
}
{
    "status": false,
    "message": "No saved items found for the specified type"
}
{
    "status": false,
    "message": "The type field is required",
    "errors": {
        "type": [
            "The type field is required"
        ]
    }
}

Store a new saved item for the authenticated user

POST
http://127.0.0.1:8000
/api/v1/saved-items

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/saved-items"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "item_id": 1,
    "type": "\"product\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Item saved successfully",
    "data": {
        "id": 1,
        "item_id": 1,
        "type": "product",
        "user_id": 1,
        "created_at": "2023-01-01T00:00:00Z",
        "updated_at": "2023-01-01T00:00:00Z"
    }
}
{
    "status": false,
    "message": "The requested item could not be found"
}
{
    "status": false,
    "message": "This item is already saved"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "item_id": [
            "The item id field is required."
        ],
        "type": [
            "The type field is required."
        ]
    }
}

Remove a saved item for the authenticated user

DELETE
http://127.0.0.1:8000
/api/v1/saved-items/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the saved item.

Example:
consequatur
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/saved-items/consequatur"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Saved item removed successfully"
}
{
    "status": false,
    "message": "Unauthenticated"
}
{
    "status": false,
    "message": "You are not authorized to remove this saved item"
}
{
    "status": false,
    "message": "Saved item not found"
}

Shipping Address Management

Get all shipping addresses for the authenticated user

GET
http://127.0.0.1:8000
/api/v1/shipping-addresses

Lists all shipping addresses associated with the current user's account, including primary/default address status

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping addresses retrieved successfully",
    "data": [
        {
            "id": 1,
            "user_id": 1,
            "name": "John Doe",
            "address": "123 Main St",
            "city": "New York",
            "state": "NY",
            "country": "USA",
            "postal_code": "10001",
            "phone": "+1234567890",
            "is_primary": true,
            "slug": "john-doe-123-main-st"
        }
    ]
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "No shipping addresses found",
    "data": []
}

Update a shipping address for the authenticated user

PATCH
http://127.0.0.1:8000
/api/v1/shipping-addresses/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the shipping address.

Example:
velit

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses/velit"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "John Doe",
    "address": "123 Main St",
    "city": "New York",
    "state": "NY",
    "country": "USA",
    "postal_code": "10001",
    "phone": "+1234567890",
    "is_primary": true
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping address updated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "name": "John Doe",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "country": "USA",
        "postal_code": "10001",
        "phone": "+1234567890",
        "is_primary": true,
        "slug": "john-doe-123-main-st"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "Shipping address not found",
    "errors": {
        "message": "The requested shipping address does not exist"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "address": [
            "The address field is required"
        ],
        "city": [
            "The city field is required"
        ],
        "state": [
            "The state field is required"
        ],
        "country": [
            "The country field is required"
        ],
        "postal_code": [
            "The postal code field is required"
        ],
        "phone": [
            "The phone field is required"
        ]
    }
}

Create a new shipping address for the authenticated user

POST
http://127.0.0.1:8000
/api/v1/shipping-addresses

Stores a new shipping address with the provided details. The address can optionally be set as the primary/default shipping address.

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "John Doe",
    "address": "123 Main St",
    "city": "New York",
    "state": "NY",
    "country": "USA",
    "postal_code": "10001",
    "phone": "+1234567890",
    "is_primary": true
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping address created successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "name": "John Doe",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "country": "USA",
        "postal_code": "10001",
        "phone": "+1234567890",
        "is_primary": true,
        "slug": "john-doe-123-main-st"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "address": [
            "The address field is required"
        ],
        "city": [
            "The city field is required"
        ],
        "state": [
            "The state field is required"
        ],
        "country": [
            "The country field is required"
        ],
        "postal_code": [
            "The postal code field is required"
        ],
        "phone": [
            "The phone field is required"
        ]
    }
}

Shipping Addresses

Get a single shipping address by slug

GET
http://127.0.0.1:8000
/api/v1/shipping-addresses/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique identifier of the shipping address.

Example:
john-doe-123-main-st
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses/john-doe-123-main-st"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping address retrieved successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "name": "John Doe",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "country": "USA",
        "postal_code": "10001",
        "phone": "+1234567890",
        "is_primary": true,
        "slug": "john-doe-123-main-st",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "Shipping address not found",
    "errors": {
        "message": "The requested shipping address does not exist"
    }
}

Set a shipping address as the primary/default address

PATCH
http://127.0.0.1:8000
/api/v1/shipping-addresses/primary/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique identifier of the shipping address to set as primary.

Example:
john-doe-123-main-st
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses/primary/john-doe-123-main-st"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "PATCH",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping address set as primary successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "name": "John Doe",
        "address": "123 Main St",
        "city": "New York",
        "state": "NY",
        "country": "USA",
        "postal_code": "10001",
        "phone": "+1234567890",
        "is_primary": true,
        "slug": "john-doe-123-main-st",
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "Shipping address not found",
    "errors": {
        "message": "The requested shipping address does not exist"
    }
}

Remove a shipping address from the user's account

DELETE
http://127.0.0.1:8000
/api/v1/shipping-addresses/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The unique identifier of the shipping address to delete.

Example:
john-doe-123-main-st
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shipping-addresses/john-doe-123-main-st"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shipping address removed successfully",
    "data": null
}
{
    "status": false,
    "message": "Unauthorized access",
    "errors": {
        "message": "Please login to access this resource"
    }
}
{
    "status": false,
    "message": "Shipping address not found",
    "errors": {
        "message": "The requested shipping address does not exist"
    }
}
{
    "status": false,
    "message": "Cannot delete primary shipping address",
    "errors": {
        "message": "Please set another address as primary before deleting this address"
    }
}

Shopping Cart

Get the current user's shopping cart items.

GET
http://127.0.0.1:8000
/api/v1/shopping-cart

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shopping-cart"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Shopping cart items retrieved successfully",
    "data": {
        "items": [
            {
                "id": 1,
                "product_id": 1,
                "quantity": 2,
                "product": {
                    "id": 1,
                    "name": "Sample Product",
                    "price": 99.99,
                    "image": "product-image.jpg"
                }
            }
        ],
        "total": 199.98
    }
}
{
    "status": false,
    "message": "Unauthenticated",
    "data": null
}
{
    "status": false,
    "message": "Shopping cart not found",
    "data": null
}

Add a product to the shopping cart.

POST
http://127.0.0.1:8000
/api/v1/shopping-cart

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shopping-cart"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "product_id": 1,
    "quantity": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Product added to cart successfully",
    "data": {
        "items": [
            {
                "id": 1,
                "product_id": 1,
                "quantity": 1,
                "product": {
                    "id": 1,
                    "name": "Sample Product",
                    "price": 99.99,
                    "image": "product-image.jpg"
                }
            }
        ],
        "total": 99.99
    }
}
{
    "status": false,
    "message": "Unauthenticated",
    "data": null
}
{
    "status": false,
    "message": "Product not found",
    "data": null
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "product_id": [
            "The product id field is required."
        ],
        "quantity": [
            "The quantity field is required."
        ]
    }
}

Shopping Cart Management

Remove a product from the shopping cart.

DELETE
http://127.0.0.1:8000
/api/v1/shopping-cart/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the shopping cart.

Example:
et
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shopping-cart/et"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Product removed from cart successfully",
    "data": {
        "items": [
            {
                "id": 2,
                "product_id": 2,
                "quantity": 1,
                "product": {
                    "id": 2,
                    "name": "Other Product",
                    "price": 49.99,
                    "image": "other-product-image.jpg"
                }
            }
        ],
        "total": 49.99
    }
}
{
    "status": false,
    "message": "Unauthenticated",
    "data": null
}
{
    "status": false,
    "message": "Cart item not found",
    "data": null
}

Update items in the shopping cart.

PATCH
http://127.0.0.1:8000
/api/v1/shopping-cart/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the shopping cart.

Example:
distinctio

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/shopping-cart/distinctio"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "quantity": 2
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Cart updated successfully",
    "data": {
        "items": [
            {
                "id": 1,
                "product_id": 1,
                "quantity": 2,
                "product": {
                    "id": 1,
                    "name": "Sample Product",
                    "price": 29.99,
                    "image": "product-image.jpg"
                }
            }
        ],
        "total": 59.98
    }
}
{
    "status": false,
    "message": "Unauthenticated",
    "data": null
}
{
    "status": false,
    "message": "Cart item not found",
    "data": null
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "quantity": [
            "The quantity field is required",
            "The quantity must be at least 1"
        ]
    }
}

Sub Category Management

Create a new sub category

POST
http://127.0.0.1:8000
/api/v1/sub-categories

Creates a new sub category with the provided details

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "Electronics",
    "slug": "electronics",
    "category_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub category created successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "category_id": 1,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Sub category with this slug already exists",
    "error": "Duplicate entry"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "category_id": [
            "The category id field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Get all sub categories

GET
http://127.0.0.1:8000
/api/v1/sub-categories

Lists all available sub categories in the system

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub categories retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Electronics",
            "slug": "electronics",
            "category_id": 1,
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "No sub categories found",
    "data": []
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Get Sub Categories by Category ID

GET
http://127.0.0.1:8000
/api/v1/sub-categories/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the sub category.

Example:
mollitia
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories/mollitia"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub categories retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Electronics",
            "slug": "electronics",
            "category_id": 1,
            "created_at": "2023-01-01T00:00:00.000000Z",
            "updated_at": "2023-01-01T00:00:00.000000Z"
        }
    ]
}
{
    "status": false,
    "message": "Category not found",
    "error": "The specified category does not exist"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Get Single Sub Category Details

GET
http://127.0.0.1:8000
/api/v1/sub-categories/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the sub category.

Example:
quam
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories/quam"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub category retrieved successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "category_id": 1,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T00:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Sub category not found",
    "error": "The specified sub category does not exist"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Update Sub Category Details

PATCH
http://127.0.0.1:8000
/api/v1/sub-categories/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the sub category.

Example:
et

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories/et"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "Updated Electronics",
    "category_id": 1
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub category updated successfully",
    "data": {
        "id": 1,
        "name": "Updated Electronics",
        "slug": "updated-electronics",
        "category_id": 1,
        "created_at": "2023-01-01T00:00:00.000000Z",
        "updated_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Sub category not found",
    "error": "The specified sub category does not exist"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "name": [
            "The name field is required"
        ],
        "category_id": [
            "The category id field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Delete a sub category by its slug

DELETE
http://127.0.0.1:8000
/api/v1/sub-categories/{slug}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

slug
string
required

The slug of the sub category.

Example:
dolores
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/sub-categories/dolores"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Sub category deleted successfully",
    "data": {
        "id": 1,
        "name": "Electronics",
        "slug": "electronics",
        "category_id": 1,
        "deleted_at": "2023-01-01T12:00:00.000000Z"
    }
}
{
    "status": false,
    "message": "Sub category not found",
    "error": "The specified sub category does not exist"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Error message details"
}

Transactions

Get all transactions

GET
http://127.0.0.1:8000
/api/v1/transactions

Lists all transactions with optional filtering parameters

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Query Parameters

page
integer

Page number for pagination.

Example:
1
per_page
integer

Number of items per page.

Example:
10
sort
string

Sort field (created_at, amount, etc).

Example:
created_at
order
string

Sort order (asc or desc).

Example:
desc
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions"
);

const params = {
    "page": "1",
    "per_page": "10",
    "sort": "created_at",
    "order": "desc",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transactions retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "trans_ref": "TRX-123456",
                "amount": 1000,
                "status": "completed",
                "created_at": "2023-01-01T12:00:00Z",
                "updated_at": "2023-01-01T12:00:00Z"
            }
        ],
        "total": 50,
        "per_page": 10
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve transactions"
}

Retrieve a specific transaction by its reference number

GET
http://127.0.0.1:8000
/api/v1/transactions/{trans_ref}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

trans_ref
string
required

The transaction reference number.

Example:
TRX-123456
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/TRX-123456"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transaction retrieved successfully",
    "data": {
        "id": 1,
        "trans_ref": "TRX-123456",
        "amount": 1000,
        "status": "completed",
        "customer": {
            "id": 1,
            "name": "John Doe",
            "email": "john@example.com"
        },
        "created_at": "2023-01-01T12:00:00Z",
        "updated_at": "2023-01-01T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Transaction not found",
    "error": "No transaction found with reference TRX-123456"
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve transaction details"
}

Get Transaction Details by Order

GET
http://127.0.0.1:8000
/api/v1/transactions/fetch/order

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/fetch/order"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "order_id": "ORD-123456",
    "include_customer": true
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transaction details retrieved successfully",
    "data": {
        "id": 1,
        "order_id": "ORD-123456",
        "trans_ref": "TRX-789012",
        "amount": 1500,
        "status": "completed",
        "payment_method": "card",
        "customer": {
            "id": 1,
            "name": "John Doe",
            "email": "john@example.com"
        },
        "created_at": "2023-01-01T12:00:00Z",
        "updated_at": "2023-01-01T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Order not found",
    "error": "No transaction found for order ORD-123456"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "order_id": [
            "The order_id field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve transaction details"
}

Filter Transactions By Date Range

GET
http://127.0.0.1:8000
/api/v1/transactions/filter/date

Retrieves a list of transactions filtered by a specified date range

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/filter/date"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "start_date": "2023-01-01",
    "end_date": "2023-12-31",
    "page": 1,
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transactions retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "transaction_id": "TRX-123456",
                "amount": 100,
                "status": "completed",
                "created_at": "2023-01-01T12:00:00Z",
                "updated_at": "2023-01-01T12:00:00Z"
            }
        ],
        "total": 50,
        "per_page": 10,
        "last_page": 5
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "start_date": [
            "The start date field is required"
        ],
        "end_date": [
            "End date must be after or equal to start date"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve transactions"
}

Filter Transactions By Status

GET
http://127.0.0.1:8000
/api/v1/transactions/filter/status

Retrieves a list of transactions filtered by their status (e.g., pending, completed, failed)

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/filter/status"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "completed",
    "page": 1,
    "per_page": 10
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transactions retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "transaction_id": "TRX-123456",
                "amount": 100,
                "status": "completed",
                "created_at": "2023-01-01T12:00:00Z",
                "updated_at": "2023-01-01T12:00:00Z"
            }
        ],
        "total": 50,
        "per_page": 10,
        "last_page": 5
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "status": [
            "The status field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve transactions"
}

Get transactions for a specific customer with optional filters

GET
http://127.0.0.1:8000
/api/v1/transactions/filter/customer

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/filter/customer"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Customer transactions retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "transaction_id": "TRX-123456",
                "customer_id": "CUST-123",
                "amount": 100,
                "status": "completed",
                "created_at": "2023-01-01T12:00:00Z",
                "updated_at": "2023-01-01T12:00:00Z"
            }
        ],
        "total": 50,
        "per_page": 10,
        "last_page": 5
    }
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Customer not found",
    "error": "The specified customer does not exist"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "customer_id": [
            "The customer ID field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to retrieve customer transactions"
}

Process a payment request for a transaction

POST
http://127.0.0.1:8000
/api/v1/transactions/payment-request

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/payment-request"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "amount": "100.50",
    "currency": "USD",
    "payment_method": "credit_card",
    "customer_id": "CUST-123",
    "description": "Payment for order #123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Payment request processed successfully",
    "data": {
        "transaction_id": "TRX-123456",
        "amount": 100.5,
        "currency": "USD",
        "payment_method": "credit_card",
        "status": "pending",
        "created_at": "2023-01-01T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Invalid payment method",
    "error": "The selected payment method is not supported"
}
{
    "status": false,
    "message": "Unauthorized access",
    "error": "Invalid or missing API token"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "amount": [
            "The amount field is required"
        ],
        "currency": [
            "The currency field is required"
        ],
        "payment_method": [
            "The payment method field is required"
        ],
        "customer_id": [
            "The customer ID field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to process payment request"
}

Generate payment details for a transaction

POST
http://127.0.0.1:8000
/api/v1/transactions/payment-details

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/payment-details"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "transaction_id": "TRX-123456",
    "customer_id": "CUST-789",
    "payment_type": "credit_card"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Payment details generated successfully",
    "data": {
        "transaction_id": "TRX-123456",
        "payment_details": {
            "amount": 150,
            "currency": "USD",
            "payment_method": "credit_card",
            "payment_instructions": "Complete payment using provided details",
            "expiry_time": "2023-12-31T23:59:59Z"
        }
    }
}
{
    "status": false,
    "message": "Invalid payment type",
    "error": "The specified payment type is not supported"
}
{
    "status": false,
    "message": "Transaction not found",
    "error": "The specified transaction could not be found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "transaction_id": [
            "The transaction ID field is required"
        ],
        "customer_id": [
            "The customer ID field is required"
        ],
        "payment_type": [
            "The payment type field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to generate payment details"
}

Process a refund for a transaction payment

POST
http://127.0.0.1:8000
/api/v1/transactions/payment-refund

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/payment-refund"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "transaction_id": "TRX-123456",
    "amount": "100.50",
    "reason": "Customer dissatisfaction"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Refund processed successfully",
    "data": {
        "refund_id": "REF-123456",
        "transaction_id": "TRX-123456",
        "amount": 100.5,
        "status": "completed",
        "processed_at": "2023-12-31T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Invalid refund request",
    "error": "The refund amount exceeds the original transaction amount"
}
{
    "status": false,
    "message": "Transaction not found",
    "error": "The specified transaction could not be found"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "transaction_id": [
            "The transaction ID field is required"
        ],
        "amount": [
            "The amount field is required and must be numeric"
        ],
        "reason": [
            "The reason field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to process refund"
}

Store a new transaction in the system

POST
http://127.0.0.1:8000
/api/v1/transactions/store

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/store"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "amount": "150.00",
    "payment_method": "credit_card",
    "currency": "USD",
    "customer_id": "CUST-123",
    "description": "Purchase of items"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transaction created successfully",
    "data": {
        "transaction_id": "TRX-123456",
        "amount": 150,
        "currency": "USD",
        "payment_method": "credit_card",
        "customer_id": "CUST-123",
        "status": "completed",
        "created_at": "2023-12-31T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Invalid payment method",
    "error": "The selected payment method is not supported"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "amount": [
            "The amount field is required and must be numeric"
        ],
        "payment_method": [
            "The payment method field is required"
        ],
        "currency": [
            "The currency field is required"
        ],
        "customer_id": [
            "The customer ID field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to process transaction"
}

Validate a transaction request before processing

POST
http://127.0.0.1:8000
/api/v1/transactions/validate

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

Body Parameters

Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/transactions/validate"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "amount": "100.50",
    "currency": "USD",
    "payment_method": "credit_card",
    "customer_id": "CUST-123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
Example response:
{
    "status": true,
    "message": "Transaction validation successful",
    "data": {
        "amount": 100.5,
        "currency": "USD",
        "payment_method": "credit_card",
        "customer_id": "CUST-123",
        "validation_id": "VAL-123456",
        "validated_at": "2023-12-31T12:00:00Z"
    }
}
{
    "status": false,
    "message": "Invalid transaction request",
    "error": "The provided payment method is not supported"
}
{
    "status": false,
    "message": "Validation failed",
    "errors": {
        "amount": [
            "The amount field is required and must be numeric"
        ],
        "currency": [
            "The currency field is required and must be a valid currency code"
        ],
        "payment_method": [
            "The payment method field is required"
        ],
        "customer_id": [
            "The customer ID field is required"
        ]
    }
}
{
    "status": false,
    "message": "Internal server error",
    "error": "Failed to validate transaction"
}

Ungrouped

DELETE api/v1/feedbacks/{id}

DELETE
http://127.0.0.1:8000
/api/v1/feedbacks/{id}

Headers

Content-Type
Example:
application/json
Accept
Example:
application/json

URL Parameters

id
string
required

The ID of the feedback.

Example:
esse
Example request:
const url = new URL(
    "http://127.0.0.1:8000/api/v1/feedbacks/esse"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());