API Reference
Introduction
Welcome to the API Reference for our platform. This document details all available API endpoints, their request and response formats, and usage guidelines. Use this API to programmatically interact with user, product, and order data.
All API requests should be made over HTTPS. The base URL for all API endpoints is: https://api.example.com/v1
Authentication
Authentication is performed by passing an API key in the Authorization header of your requests.
Required Headers
AuthorizationBearer YOUR_API_KEY
Replace YOUR_API_KEY with your actual API key. You can obtain an API key from your developer dashboard.
Users API
Retrieves a list of all users.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit |
Integer | No | Maximum number of users to return. Defaults to 20. |
offset |
Integer | No | Number of users to skip before starting to collect the result set. Defaults to 0. |
status |
String | No | Filter users by status (e.g., active, inactive). |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved list of users. |
|
401 Unauthorized |
Authentication failed. |
|
Creates a new user.
Request Body
application/json{
"name": "Charlie Chaplin",
"email": "charlie@example.com",
"status": "active"
}
Responses
| Status Code | Description | Example |
|---|---|---|
201 Created |
User successfully created. |
|
400 Bad Request |
Invalid input data. |
|
Retrieves a specific user by their ID.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId |
String | Yes | The unique identifier of the user. |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved user details. |
|
404 Not Found |
User with the specified ID was not found. |
|
Updates an existing user.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId |
String | Yes | The unique identifier of the user to update. |
Request Body
application/json{
"name": "Alice Smith",
"status": "inactive"
}
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
User successfully updated. |
|
404 Not Found |
User not found. |
|
Deletes a user by their ID.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId |
String | Yes | The unique identifier of the user to delete. |
Responses
| Status Code | Description | Example |
|---|---|---|
204 No Content |
User successfully deleted. | (No response body) |
404 Not Found |
User not found. |
|
Products API
Retrieves a list of all products.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
category |
String | No | Filter products by category. |
limit |
Integer | No | Maximum number of products to return. Defaults to 50. |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved list of products. |
|
Creates a new product.
Request Body
application/json{
"name": "Ergonomic Chair",
"category": "Furniture",
"price": 199.99,
"in_stock": true,
"description": "Comfortable ergonomic chair for long working hours."
}
Responses
| Status Code | Description | Example |
|---|---|---|
201 Created |
Product successfully created. |
|
Retrieves a specific product by its ID.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId |
String | Yes | The unique identifier of the product. |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved product details. |
|
404 Not Found |
Product not found. |
|
Updates an existing product.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId |
String | Yes | The unique identifier of the product to update. |
Request Body
application/json{
"price": 27.50,
"in_stock": false
}
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Product successfully updated. |
|
404 Not Found |
Product not found. |
|
Deletes a product by its ID.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
productId |
String | Yes | The unique identifier of the product to delete. |
Responses
| Status Code | Description | Example |
|---|---|---|
204 No Content |
Product successfully deleted. | (No response body) |
404 Not Found |
Product not found. |
|
Orders API
Retrieves a list of all 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). |
limit |
Integer | No | Maximum number of orders to return. Defaults to 50. |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved list of orders. |
|
Creates a new order.
Request Body
application/json{
"user_id": "usr_123abc",
"items": [
{
"product_id": "prod_abc123",
"quantity": 2
},
{
"product_id": "prod_ghi789",
"quantity": 1
}
]
}
Responses
| Status Code | Description | Example |
|---|---|---|
201 Created |
Order successfully created. |
|
400 Bad Request |
Invalid input data, e.g., product not found or insufficient stock. |
|
Retrieves a specific order by its ID.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
orderId |
String | Yes | The unique identifier of the order. |
Responses
| Status Code | Description | Example |
|---|---|---|
200 OK |
Successfully retrieved order details. |
|
404 Not Found |
Order not found. |
|