User Management API
GET
/api/v1/users
Retrieves a list of all users. Supports pagination and filtering.
Query Parameters
Name | Type | Required | Description |
---|---|---|---|
page | integer | No | The page number for pagination. |
limit | integer | No | The number of results per page. |
status | string | No | Filter by user status (e.g., 'active', 'inactive'). |
Success Response (200 OK)
[
{
"id": "usr_abc123",
"username": "johndoe",
"email": "john.doe@example.com",
"status": "active",
"createdAt": "2023-10-27T10:00:00Z"
},
{
"id": "usr_def456",
"username": "janedoe",
"email": "jane.doe@example.com",
"status": "active",
"createdAt": "2023-10-27T10:05:00Z"
}
]
GET
/api/v1/users/{userId}
Retrieves details for a specific user by their ID.
Path Parameters
Name | Type | Required | Description |
---|---|---|---|
userId | string | Yes | The unique identifier of the user. |
Success Response (200 OK)
{
"id": "usr_abc123",
"username": "johndoe",
"email": "john.doe@example.com",
"status": "active",
"createdAt": "2023-10-27T10:00:00Z",
"updatedAt": "2023-10-27T11:30:00Z"
}
POST
/api/v1/users
Creates a new user account.
Request Body (application/json)
{
"username": "newuser",
"email": "new.user@example.com",
"password": "securepassword123"
}
Success Response (201 Created)
{
"id": "usr_ghi789",
"username": "newuser",
"email": "new.user@example.com",
"status": "pending_verification",
"createdAt": "2023-10-27T12:00:00Z"
}
PUT
/api/v1/users/{userId}
Updates an existing user's information.
Path Parameters
Name | Type | Required | Description |
---|---|---|---|
userId | string | Yes | The unique identifier of the user to update. |
Request Body (application/json)
{
"email": "john.doe.updated@example.com",
"status": "active"
}
Success Response (200 OK)
{
"id": "usr_abc123",
"username": "johndoe",
"email": "john.doe.updated@example.com",
"status": "active",
"createdAt": "2023-10-27T10:00:00Z",
"updatedAt": "2023-10-27T13:00:00Z"
}
DELETE
/api/v1/users/{userId}
Deletes a user account.
Path Parameters
Name | Type | Required | Description |
---|---|---|---|
userId | string | Yes | The unique identifier of the user to delete. |
Success Response (204 No Content)
No content is returned on successful deletion.
Product Catalog API
GET
/api/v1/products
Retrieves a list of products. Supports searching and sorting.
Query Parameters
Name | Type | Required | Description |
---|---|---|---|
search | string | No | Search term for product name or description. |
category | string | No | Filter by product category. |
sortBy | string | No | Field to sort by (e.g., 'price', 'name', 'createdAt'). |
order | string | No | Sort order ('asc' or 'desc'). Defaults to 'asc'. |
Success Response (200 OK)
[
{
"id": "prod_xyz789",
"name": "Wireless Mouse",
"description": "Ergonomic wireless mouse with long battery life.",
"price": 25.99,
"category": "Electronics",
"stock": 150
},
{
"id": "prod_uvw456",
"name": "Mechanical Keyboard",
"description": "RGB mechanical keyboard with customizable keycaps.",
"price": 79.99,
"category": "Electronics",
"stock": 80
}
]
POST
/api/v1/products
Adds a new product to the catalog.
Request Body (application/json)
{
"name": "USB-C Hub",
"description": "7-in-1 USB-C Hub with HDMI, USB 3.0, and SD card reader.",
"price": 35.50,
"category": "Accessories",
"stock": 200
}
Success Response (201 Created)
{
"id": "prod_abc012",
"name": "USB-C Hub",
"description": "7-in-1 USB-C Hub with HDMI, USB 3.0, and SD card reader.",
"price": 35.50,
"category": "Accessories",
"stock": 200,
"createdAt": "2023-10-27T14:00:00Z"
}
Order Processing API
GET
/api/v1/orders
Retrieves a list of orders.
Query Parameters
Name | Type | Required | Description |
---|---|---|---|
userId | string | No | Filter orders by user ID. |
status | string | No | Filter orders by status (e.g., 'pending', 'shipped', 'delivered'). |
Success Response (200 OK)
[
{
"id": "ord_987654",
"userId": "usr_abc123",
"orderDate": "2023-10-27T15:00:00Z",
"totalAmount": 105.99,
"status": "processing",
"items": [
{"productId": "prod_xyz789", "quantity": 1, "price": 25.99},
{"productId": "prod_uvw456", "quantity": 1, "price": 79.99}
]
}
]
POST
/api/v1/orders
Creates a new order.
Request Body (application/json)
{
"userId": "usr_abc123",
"items": [
{"productId": "prod_abc012", "quantity": 2},
{"productId": "prod_xyz789", "quantity": 1}
],
"shippingAddress": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "90210"
}
}
Success Response (201 Created)
{
"id": "ord_112233",
"userId": "usr_abc123",
"orderDate": "2023-10-27T16:00:00Z",
"totalAmount": 91.48,
"status": "pending",
"items": [
{"productId": "prod_abc012", "quantity": 2, "price": 35.50},
{"productId": "prod_xyz789", "quantity": 1, "price": 25.99}
],
"shippingAddress": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "90210"
}
}