API Documentation

Introduction

Welcome to the API documentation. This API provides access to user data and related functionalities. You can retrieve, create, update, and delete user records through this interface.

Our API follows RESTful principles and uses JSON for request and response bodies. All requests should be made over HTTPS.

Authentication

Authentication is handled via API keys. Include your API key in the Authorization header of every request:

Authorization: Bearer YOUR_API_KEY

Requests without valid authentication will receive a 401 Unauthorized response.

Endpoints

GET /users

Retrieve a list of all users.

Query Parameters:

Name Type Required Description
limit Integer No Maximum number of users to return.
offset Integer No Number of users to skip before starting to collect the result set.

Responses:

200 OK

[
    {
        "id": "user_abc123",
        "username": "johndoe",
        "email": "john.doe@example.com",
        "created_at": "2023-10-27T10:00:00Z"
    },
    {
        "id": "user_def456",
        "username": "janedoe",
        "email": "jane.doe@example.com",
        "created_at": "2023-10-27T10:05:00Z"
    }
]

GET /users/{userId}

Retrieve a specific user by their ID.

Path Parameters:

Name Type Required Description
userId String Yes The unique identifier of the user.

Responses:

200 OK

{
    "id": "user_abc123",
    "username": "johndoe",
    "email": "john.doe@example.com",
    "created_at": "2023-10-27T10:00:00Z",
    "updated_at": "2023-10-27T11:30:00Z"
}

404 Not Found

{
    "error": "User not found"
}

POST /users

Create a new user.

Request Body:

The request body should be a JSON object containing user details:

{
    "username": "newuser",
    "email": "new.user@example.com",
    "password": "securepassword123"
}

Responses:

201 Created

{
    "id": "user_ghi789",
    "username": "newuser",
    "email": "new.user@example.com",
    "created_at": "2023-10-27T12:00:00Z"
}

400 Bad Request

{
    "error": "Invalid input data",
    "details": {
        "email": "Email format is invalid."
    }
}

PUT /users/{userId}

Update an existing user's details.

Path Parameters:

Name Type Required Description
userId String Yes The unique identifier of the user to update.

Request Body:

The request body should be a JSON object containing the fields to update:

{
    "email": "john.doe.updated@example.com"
}

Responses:

200 OK

{
    "id": "user_abc123",
    "username": "johndoe",
    "email": "john.doe.updated@example.com",
    "created_at": "2023-10-27T10:00:00Z",
    "updated_at": "2023-10-27T13:15:00Z"
}

404 Not Found

{
    "error": "User not found"
}

DELETE /users/{userId}

Delete a user by their ID.

Path Parameters:

Name Type Required Description
userId String Yes The unique identifier of the user to delete.

Responses:

204 No Content

Successfully deleted the user.

404 Not Found

{
    "error": "User not found"
}

Error Handling

The API uses standard HTTP status codes to indicate the success or failure of a request. Error responses will typically include a JSON object with an error message and often more specific details.

Common error codes include:

Rate Limiting

To ensure fair usage and stability, the API enforces rate limits. You are allowed a maximum of 100 requests per minute per API key.

If you exceed the rate limit, you will receive a 429 Too Many Requests response. The response headers will include: