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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay