API Reference

This section details the various endpoints available through the MSDN API, their parameters, request/response formats, and common usage examples.

Users API

Endpoints for managing user data, including retrieval, creation, and updates.

GET /users

GET /users

Retrieves a list of all users.

Query Parameters
limit [optional, number]
The maximum number of users to return.
offset [optional, number]
The number of users to skip before starting to collect the result set.
Response (200 OK)
[
  {
    "id": "usr_abc123",
    "username": "john_doe",
    "email": "john.doe@example.com",
    "createdAt": "2023-10-27T10:00:00Z"
  },
  {
    "id": "usr_def456",
    "username": "jane_smith",
    "email": "jane.smith@example.com",
    "createdAt": "2023-10-27T10:05:00Z"
  }
]

Example Request

fetch('/users?limit=2')

GET /users/{id}

GET /users/:id

Retrieves a specific user by their ID.

Path Parameters
id [required, string]
The unique identifier of the user.
Response (200 OK)
{
  "id": "usr_abc123",
  "username": "john_doe",
  "email": "john.doe@example.com",
  "createdAt": "2023-10-27T10:00:00Z",
  "updatedAt": "2023-10-27T11:30:00Z"
}
Response (404 Not Found)
{
  "error": "User not found"
}

Example Request

fetch('/users/usr_abc123')

POST /users

POST /users

Creates a new user.

Request Body
username [required, string]
The desired username for the new user.
email [required, string]
The email address of the new user.
password [required, string]
The password for the new user.
Response (201 Created)
{
  "id": "usr_ghi789",
  "username": "new_user",
  "email": "new.user@example.com",
  "createdAt": "2023-10-27T12:00:00Z"
}

Example Request

fetch('/users', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    username: 'new_user',
    email: 'new.user@example.com',
    password: 'securepassword123'
  })
})

Products API

Endpoints for managing product catalog, including retrieval, creation, and updates.

GET /products

GET /products

Retrieves a list of all available products.

Query Parameters
category [optional, string]
Filter products by category.
search [optional, string]
Search term to filter products by name or description.
Response (200 OK)
[
  {
    "id": "prod_xyz789",
    "name": "Deluxe Widget",
    "description": "A premium widget with enhanced features.",
    "price": 199.99,
    "category": "Widgets"
  },
  {
    "id": "prod_uvw012",
    "name": "Standard Gadget",
    "description": "An everyday gadget for your needs.",
    "price": 49.50,
    "category": "Gadgets"
  }
]

Orders API

Endpoints for managing customer orders.

POST /orders

POST /orders

Creates a new order.

Request Body
userId [required, string]
The ID of the user placing the order.
items [required, array]
An array of objects, each representing an item in the order.
Each item object should have productId (string) and quantity (number).
shippingAddress [required, object]
Details of the shipping address.
Response (201 Created)
{
  "id": "ord_lmn345",
  "userId": "usr_abc123",
  "status": "Pending",
  "createdAt": "2023-10-27T13:00:00Z",
  "totalAmount": 249.49
}

Example Request

fetch('/orders', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    userId: 'usr_abc123',
    items: [
      { productId: 'prod_xyz789', quantity: 1 },
      { productId: 'prod_uvw012', quantity: 1 }
    ],
    shippingAddress: {
      street: '123 Main St',
      city: 'Anytown',
      zip: '12345'
    }
  })
})