DEV Community

Cover image for Sample of API Documentation for Inventory Management System
Ashik Rahman
Ashik Rahman

Posted on

Sample of API Documentation for Inventory Management System

1. Authentication

Register User

Endpoint: POST /api/auth/register

  • Description: Registers a new user.
  • Request Body:
  {
    "name": "John Doe",
    "email": "john@example.com",
    "password": "password123"
  }
Enter fullscreen mode Exit fullscreen mode
  • Response:
  {
    "message": "User registered successfully",
    "user": { "id": "123", "name": "John Doe", "email": "john@example.com" }
  }
Enter fullscreen mode Exit fullscreen mode

User Login

Endpoint: POST /api/auth/login

  • Description: Logs in a user.
  • Request Body:
  {
    "email": "john@example.com",
    "password": "password123"
  }
Enter fullscreen mode Exit fullscreen mode
  • Response:
  {
    "token": "jwt-token-here"
  }
Enter fullscreen mode Exit fullscreen mode

2. Products

Get All Products

Endpoint: GET /api/products

  • Description: Fetch all available products.
  • Response:
  [
    {
      "id": "1",
      "name": "Laptop",
      "description": "Gaming Laptop",
      "price": 1200,
      "stock": 10,
      "category": "Electronics"
    }
  ]
Enter fullscreen mode Exit fullscreen mode

Add New Product

Endpoint: POST /api/products

  • Description: Adds a new product (Admin Only).
  • Request Body:
  {
    "name": "Laptop",
    "description": "Gaming Laptop",
    "price": 1200,
    "stock": 10,
    "category": "Electronics"
  }
Enter fullscreen mode Exit fullscreen mode
  • Response:
  {
    "message": "Product added successfully",
    "product": { "id": "1", "name": "Laptop" }
  }
Enter fullscreen mode Exit fullscreen mode

3. Orders

Place an Order

Endpoint: POST /api/orders

  • Description: Places a new order.
  • Request Body:
  {
    "userId": "123",
    "products": [
      { "productId": "1", "quantity": 2 }
    ],
    "totalPrice": 2400
  }
Enter fullscreen mode Exit fullscreen mode
  • Response:
  {
    "message": "Order placed successfully",
    "orderId": "456"
  }
Enter fullscreen mode Exit fullscreen mode

Get User Orders

Endpoint: GET /api/orders/{userId}

  • Description: Fetches all orders placed by a user.
  • Response:
  [
    {
      "id": "456",
      "userId": "123",
      "products": [
        { "productId": "1", "quantity": 2 }
      ],
      "totalPrice": 2400,
      "status": "pending"
    }
  ]
Enter fullscreen mode Exit fullscreen mode

4. Payments

Process Payment

Endpoint: POST /api/payments

  • Description: Processes a payment for an order.
  • Request Body:
  {
    "orderId": "456",
    "amount": 2400,
    "method": "bKash"
  }
Enter fullscreen mode Exit fullscreen mode
  • Response:
  {
    "message": "Payment successful",
    "paymentId": "789"
  }
Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay