Skip to content

Repository files navigation

Dokan - E-Commerce API

"Dokan" is a robust e-commerce platform designed to empower merchants and entrepreneurs with seamless online selling capabilities. It offers a user-friendly interface for setting up and managing digital storefronts, enabling businesses to showcase their products effectively. Dokan supports various features like customizable storefronts, multi-vendor functionality, secure payment gateways, and extensive product management tools. It fosters a vibrant marketplace where sellers can reach a wide audience, while buyers enjoy a rich shopping experience with diverse product offerings. With its scalable architecture and intuitive design, Dokan facilitates the growth and success of e-commerce ventures across different industries.

Product Management

1. Create a New Product

  • Endpoint: /api/products

  • Method:POST

  • Sample Request Body:

    {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 50,
    "inStock": true
    }
    }
  • Sample Response:

    {
    "success": true,
    "message": "Product created successfully!",
    "data": {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 50,
    "inStock": true
    }
    }
    }

2. Retrieve a List of All Products

  • Endpoint: /api/products

  • Method:GET

  • Sample Response:

    {
    "success": true,
    "message": "Products fetched successfully!",
    "data": [
    {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 50,
    "inStock": true
    }
    },
    {
    "name": "Samsung Galaxy S21",
    "description": "High-performance Android smartphone with advanced camera capabilities.",
    "price": 799,
    "category": "Electronics",
    "tags": ["smartphone", "Samsung", "Android"],
    "variants": [
    {
    "type": "Color",
    "value": "Phantom Black"
    },
    {
    "type": "Storage Capacity",
    "value": "128GB"
    }
    ],
    "inventory": {
    "quantity": 30,
    "inStock": true
    }
    }
    ]
    }

3. Retrieve a Specific Product by ID

  • Endpoint: /api/products/:productId

  • Method: GET

  • Sample Response:

    {
    "success": true,
    "message": "Product fetched successfully!",
    "data": {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 50,
    "inStock": true
    }
    }
    }

4. Update Product Information

  • Endpoint: /api/products/:productId

  • Method: PUT

  • Sample Request Body:

    {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 50,
    "inStock": true
    }
    }
  • Sample Response:

    {
    "success": true,
    "message": "Product updated successfully!",
    "data": {
    "name": "iPhone 13",
    "description": "A sleek and powerful smartphone with cutting-edge features.",
    "price": 999,
    "category": "Electronics",
    "tags": ["smartphone", "Apple", "iOS"],
    "variants": [
    {
    "type": "Color",
    "value": "Midnight Blue"
    },
    {
    "type": "Storage Capacity",
    "value": "256GB"
    }
    ],
    "inventory": {
    "quantity": 49,
    "inStock": true
    }
    }
    }

5. Delete a Product

  • Endpoint: /api/products/:productId

  • Method: DELETE

  • Sample Response:

    {
    "success": true,
    "message": "Product deleted successfully!",
    "data": null
    }
    

6. Search a product

  • Endpoint: /api/products?searchTerm=iphone
  • Method: GET
  • Sample Response:
{"success": true,"message": "Products matching search term 'iphone' fetched successfully!","data": [{"name": "iPhone 13 Pro","description": "The latest flagship iPhone model with advanced camera features.","price": 999,"category": "Smartphones","tags": ["iPhone","Apple","Mobile"],"variants": [{"type": "Color","value": "Graphite"},{"type": "Storage","value": "256GB"}],"inventory": {"quantity": 50,"inStock": true}},{"name": "iPhone SE","description": "Compact and affordable iPhone model with powerful performance.","price": 399,"category": "Smartphones","tags": ["iPhone","Apple","Mobile"],"variants": [{"type": "Color","value": "White"},{"type": "Storage","value": "128GB"}],"inventory": {"quantity": 20,"inStock": true}}]}

Order Management

Order Management API Endpoints

1.Create a New Order

  • Endpoint: /api/orders

  • Method: POST

  • Request Body:

    {
    "email": "level2@programming-hero.com",
    "productId": "5fd67e890b60c903cd8544a3",
    "price": 999,
    "quantity": 1
    }
  • Response:

    {
    "success": true,
    "message": "Order created successfully!",
    "data": {
    "email": "level2@programming-hero.com",
    "productId": "5fd67e890b60c903cd8544a3",
    "price": 999,
    "quantity": 1
    }
    }
    

2.Retrieve All Orders

  • Endpoint: /api/orders

  • Method: GET

  • Sample Response:

    {
    "success": true,
    "message": "Orders fetched successfully!",
    "data": [
    {
    "email": "level2@programming-hero.com",
    "productId": "5fd67e890b60c903cd8544a3",
    "price": 999,
    "quantity": 1
    }
    ]
    }

3. Retrieve Orders by User Email

  • Endpoint: /api/orders?email=level2@programming-hero.com

  • Method:GET

  • Sample Response:

    {
    "success": true,
    "message": "Orders fetched successfully for user email!",
    "data": [
    {
    "email": "level2@programming-hero.com",
    "productId": "5fd67e890b60c903cd8544a3",
    "price": 999,
    "quantity": 1
    }
    ]
    }

Error Handling:

Sample Error Responses

  • Insufficient Quantity Error
{"success": false,"message": "Insufficient quantity available in inventory"}
  • Not Found Error
{"success": false,"message": "Order not found"}
  • Not Found Route
{"success": false,"message": "Route not found"}

Application Routes:

Product

  • /api/v1/product (POST)
  • /api/v1/product (Get All Products)
  • /api/v1/product?searchTerm=Iphone (Get Search Products)
  • api/v1/product/66862f1ef362f9c62432d131 (Single GET)
  • api/v1/product/66862f1ef362f9c62432d131 (PUT)
  • api/v1/product/66862f1ef362f9c62432d131 (DELETE)

Product

Submission Format for Our Submission Box: (Please use the following format for your submissions:)

About

Dokan is an e-commerce platform designed to empower sellers with easy storefront creation, seamless product management, and robust customer engagement features.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages