- Getting Started
- Authentication
- Response Format
- Health & System Endpoints
- User Management Endpoints
- Question Management Endpoints
- AI Assistant Endpoints
- Statistics Endpoints
- Error Handling
- Testing Tools
http://localhost:5000
For interactive testing, visit the Swagger UI:
http://localhost:5000/apidocs
All POST/PUT requests require:
Content-Type: application/json
Currently, the API does not require authentication. All endpoints are publicly accessible.
Note for Production: Implement authentication before deploying to production.
{
"status": "success",
"message": "Operation description",
"data": { /* Response data */ }
}{
"status": "error",
"message": "Error description",
"error": "Detailed error information"
}200 OK- Successful GET, PUT, DELETE201 Created- Successful POST (resource created)400 Bad Request- Validation error404 Not Found- Resource not found409 Conflict- Duplicate resource500 Internal Server Error- Server error
Check if the server is running and healthy.
Endpoint: GET /health
cURL:
curl -X GET http://localhost:5000/healthResponse:
{
"status": "healthy",
"timestamp": "2025-10-02T14:30:00.123456"
}Simple connectivity test.
Endpoint: GET /ping
cURL:
curl -X GET http://localhost:5000/pingResponse:
<h1>Pong!</h1>Create a new user account.
Endpoint: POST /users
Required Fields:
username(string) - Unique usernameemail(string) - Unique email address
cURL:
curl -X POST http://localhost:5000/users \
-H "Content-Type: application/json" \
-d '{
"username": "aruncs",
"email": "arun@example.com"
}'Response (201 Created):
{
"status": "success",
"message": "User created successfully",
"data": {
"user": {
"id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"username": "aruncs",
"email": "arun@example.com",
"created_at": "2025-10-02T14:30:00.123456",
"is_active": true
}
}
}Error Responses:
400- Validation error (missing fields)409- Username or email already exists
Retrieve a list of all registered users.
Endpoint: GET /users
cURL:
curl -X GET http://localhost:5000/usersResponse (200 OK):
{
"status": "success",
"message": "Users retrieved successfully",
"data": {
"users": [
{
"id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"username": "aruncs",
"email": "arun@example.com",
"created_at": "2025-10-02T14:30:00.123456",
"is_active": true
},
{
"id": "a1b2c3d4-1234-5678-90ab-cdef12345678",
"username": "johndoe",
"email": "john@example.com",
"created_at": "2025-10-01T10:15:30.456789",
"is_active": true
}
]
}
}Retrieve details of a specific user.
Endpoint: GET /users/{user_id}
Path Parameters:
user_id(string, UUID) - The user's unique identifier
cURL:
curl -X GET http://localhost:5000/users/d5d06cf9-036c-4342-b448-dca4307848c2Response (200 OK):
{
"status": "success",
"message": "User retrieved successfully",
"data": {
"user": {
"id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"username": "aruncs",
"email": "arun@example.com",
"created_at": "2025-10-02T14:30:00.123456",
"is_active": true
}
}
}Error Responses:
404- User not found
Update an existing user's information.
Endpoint: PUT /users/{user_id}
Path Parameters:
user_id(string, UUID) - The user's unique identifier
Optional Fields:
username(string) - New usernameemail(string) - New emailis_active(boolean) - Active status
cURL:
curl -X PUT http://localhost:5000/users/d5d06cf9-036c-4342-b448-dca4307848c2 \
-H "Content-Type: application/json" \
-d '{
"username": "arun_cs",
"email": "arun.new@example.com"
}'Response (200 OK):
{
"status": "success",
"message": "User updated successfully",
"data": {
"user": {
"id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"username": "arun_cs",
"email": "arun.new@example.com",
"created_at": "2025-10-02T14:30:00.123456",
"is_active": true
}
}
}Error Responses:
404- User not found409- Username or email already exists400- Validation error
Delete a user account.
Endpoint: DELETE /users/{user_id}
Path Parameters:
user_id(string, UUID) - The user's unique identifier
cURL:
curl -X DELETE http://localhost:5000/users/d5d06cf9-036c-4342-b448-dca4307848c2Response (200 OK):
{
"status": "success",
"message": "User deleted successfully"
}Error Responses:
404- User not found
Note: Deleting a user will also delete all their question-response records (cascade delete).
Retrieve all questions asked by a specific user.
Endpoint: GET /users/{user_id}/questions
Path Parameters:
user_id(string, UUID) - The user's unique identifier
cURL:
curl -X GET http://localhost:5000/users/d5d06cf9-036c-4342-b448-dca4307848c2/questionsResponse (200 OK):
{
"status": "success",
"message": "User questions retrieved successfully",
"data": [
{
"id": "q1a2b3c4-5678-90ab-cdef-1234567890ab",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What time is it?",
"response": "The current time is 2:30 PM",
"timestamp": "2025-10-02T14:30:00.123456",
"confidence_score": 0.95,
"response_time_ms": 234
}
]
}Error Responses:
404- User not found
Manually create a question-response record.
Endpoint: POST /questions
Required Fields:
user_id(string, UUID) - User who asked the questionquestion(string) - The question textresponse(string) - The response text
Optional Fields:
confidence_score(float, 0-1) - Confidence scoreresponse_time_ms(integer) - Response time in milliseconds
cURL:
curl -X POST http://localhost:5000/questions \
-H "Content-Type: application/json" \
-d '{
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What is artificial intelligence?",
"response": "Artificial intelligence is the simulation of human intelligence...",
"confidence_score": 0.85,
"response_time_ms": 250
}'Response (201 Created):
{
"status": "success",
"message": "Question response created successfully",
"data": {
"id": "q1a2b3c4-5678-90ab-cdef-1234567890ab",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What is artificial intelligence?",
"response": "Artificial intelligence is the simulation of human intelligence...",
"timestamp": "2025-10-02T14:30:00.123456",
"confidence_score": 0.85,
"response_time_ms": 250
}
}Error Responses:
400- Validation error (missing required fields)404- User not found
Retrieve all question-response records.
Endpoint: GET /questions
Query Parameters:
limit(integer, optional, default: 100) - Maximum records to returnoffset(integer, optional, default: 0) - Number of records to skip
cURL:
# Get all questions
curl -X GET http://localhost:5000/questions
# With pagination
curl -X GET "http://localhost:5000/questions?limit=10&offset=0"Response (200 OK):
{
"status": "success",
"message": "Question responses retrieved successfully",
"data": [
{
"id": "q1a2b3c4-5678-90ab-cdef-1234567890ab",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What is AI?",
"response": "AI is artificial intelligence...",
"timestamp": "2025-10-02T14:30:00.123456",
"confidence_score": 0.85,
"response_time_ms": 250
}
]
}Retrieve a specific question-response record.
Endpoint: GET /questions/{response_id}
Path Parameters:
response_id(string, UUID) - The question-response record ID
cURL:
curl -X GET http://localhost:5000/questions/q1a2b3c4-5678-90ab-cdef-1234567890abResponse (200 OK):
{
"status": "success",
"message": "Question response retrieved successfully",
"data": {
"id": "q1a2b3c4-5678-90ab-cdef-1234567890ab",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What is AI?",
"response": "AI is artificial intelligence...",
"timestamp": "2025-10-02T14:30:00.123456",
"confidence_score": 0.85,
"response_time_ms": 250
}
}Error Responses:
404- Question-response not found
Delete a question-response record.
Endpoint: DELETE /questions/{response_id}
Path Parameters:
response_id(string, UUID) - The question-response record ID
cURL:
curl -X DELETE http://localhost:5000/questions/q1a2b3c4-5678-90ab-cdef-1234567890abResponse (200 OK):
{
"status": "success",
"message": "Question response deleted successfully"
}Error Responses:
404- Question-response not found
Retrieve pre-configured example questions.
Endpoint: GET /api/example-questions
cURL:
curl -X GET http://localhost:5000/api/example-questionsResponse (200 OK):
{
"status": "success",
"message": "Example questions retrieved successfully",
"data": [
{
"id": 1,
"category": "General",
"question": "What time is it?",
"description": "Ask for the current time"
},
{
"id": 2,
"category": "General",
"question": "What's the date today?",
"description": "Ask for today's date"
},
{
"id": 3,
"category": "Knowledge",
"question": "Tell me about artificial intelligence",
"description": "Learn about AI"
}
]
}Ask a question to the AI assistant and get a response.
Endpoint: POST /api/ask
Required Fields:
question(string) - The question to ask
Optional Fields:
user_id(string, UUID) - User ID (if provided, saves to database)
cURL:
# Without user_id (not saved to database)
curl -X POST http://localhost:5000/api/ask \
-H "Content-Type: application/json" \
-d '{
"question": "What time is it?"
}'
# With user_id (saved to database)
curl -X POST http://localhost:5000/api/ask \
-H "Content-Type: application/json" \
-d '{
"question": "What is machine learning?",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2"
}'Response (200 OK):
{
"status": "success",
"message": "Question processed successfully",
"data": {
"question": "What time is it?",
"response": "The current time is 2:30 PM",
"confidence_score": 0.95,
"response_time_ms": 234,
"timestamp": "2025-10-02T14:30:00.123456",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2"
}
}Error Responses:
400- Validation error (missing question)404- User not found (if user_id provided)
Retrieve conversation history for a specific user.
Endpoint: GET /api/conversation/{user_id}
Path Parameters:
user_id(string, UUID) - The user's unique identifier
Query Parameters:
limit(integer, optional, default: 50) - Maximum conversations to returnoffset(integer, optional, default: 0) - Number of conversations to skip
cURL:
# Get recent conversations
curl -X GET http://localhost:5000/api/conversation/d5d06cf9-036c-4342-b448-dca4307848c2
# With pagination
curl -X GET "http://localhost:5000/api/conversation/d5d06cf9-036c-4342-b448-dca4307848c2?limit=10&offset=0"Response (200 OK):
{
"status": "success",
"message": "Conversation history retrieved successfully",
"data": [
{
"id": "q1a2b3c4-5678-90ab-cdef-1234567890ab",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "What is AI?",
"response": "AI is artificial intelligence...",
"timestamp": "2025-10-02T14:30:00.123456",
"confidence_score": 0.85,
"response_time_ms": 250
},
{
"id": "q2b3c4d5-6789-01ab-cdef-234567890abc",
"user_id": "d5d06cf9-036c-4342-b448-dca4307848c2",
"question": "Tell me more",
"response": "AI includes machine learning...",
"timestamp": "2025-10-02T14:31:15.789012",
"confidence_score": 0.82,
"response_time_ms": 312
}
]
}Error Responses:
404- User not found
Get the current status of the AI assistant.
Endpoint: GET /api/assistant/status
cURL:
curl -X GET http://localhost:5000/api/assistant/statusResponse (200 OK):
{
"status": "success",
"message": "Assistant status retrieved successfully",
"data": {
"name": "Minix",
"initialized": true,
"provider": "cohere"
}
}Reset the AI assistant's state and conversation context.
Endpoint: POST /api/assistant/reset
cURL:
curl -X POST http://localhost:5000/api/assistant/reset \
-H "Content-Type: application/json"Response (200 OK):
{
"status": "success",
"message": "Assistant reset successfully",
"data": {
"name": "Minix",
"initialized": true
}
}Error Responses:
500- Server error
Retrieve comprehensive system statistics.
Endpoint: GET /stats
cURL:
curl -X GET http://localhost:5000/statsResponse (200 OK):
{
"status": "success",
"message": "Statistics retrieved successfully",
"data": {
"total_users": 42,
"total_questions": 156,
"average_response_time_ms": 234.5,
"average_confidence_score": 0.82,
"assistant_status": {
"name": "Minix",
"initialized": true,
"provider": "cohere"
}
}
}Error Responses:
500- Server error
{
"status": "error",
"message": "Validation error",
"error": "Missing required field: username"
}{
"status": "error",
"message": "User not found",
"error": "No user found with the given ID"
}{
"status": "error",
"message": "Conflict",
"error": "Username already exists"
}{
"status": "error",
"message": "Server error",
"error": "Database connection failed"
}Visit the interactive documentation:
http://localhost:5000/apidocs
Features:
- View all endpoints
- Test API calls in browser
- See request/response schemas
- No additional tools needed
All examples above use cURL. Basic syntax:
# GET request
curl -X GET http://localhost:5000/endpoint
# POST request
curl -X POST http://localhost:5000/endpoint \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# PUT request
curl -X PUT http://localhost:5000/endpoint/id \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# DELETE request
curl -X DELETE http://localhost:5000/endpoint/idimport requests
BASE_URL = "http://localhost:5000"
# Create user
response = requests.post(
f"{BASE_URL}/users",
json={"username": "testuser", "email": "test@example.com"}
)
user_id = response.json()['data']['user']['id']
# Ask question
response = requests.post(
f"{BASE_URL}/api/ask",
json={"question": "What is AI?", "user_id": user_id}
)
print(response.json())
# Get conversation
response = requests.get(f"{BASE_URL}/api/conversation/{user_id}")
print(response.json())Import the OpenAPI specification:
- Download from:
http://localhost:5000/apispec_1.json - Import into Postman
- All endpoints will be available for testing
// Create user
fetch('http://localhost:5000/users', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
username: 'testuser',
email: 'test@example.com'
})
})
.then(res => res.json())
.then(data => {
const userId = data.data.user.id;
// Ask question
return fetch('http://localhost:5000/api/ask', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
question: 'What is AI?',
user_id: userId
})
});
})
.then(res => res.json())
.then(data => console.log(data));#!/bin/bash
BASE_URL="http://localhost:5000"
# Step 1: Create a user
echo "Creating user..."
USER_RESPONSE=$(curl -s -X POST $BASE_URL/users \
-H "Content-Type: application/json" \
-d '{"username": "john_doe", "email": "john@example.com"}')
# Extract user ID (using jq)
USER_ID=$(echo $USER_RESPONSE | jq -r '.data.user.id')
echo "Created user with ID: $USER_ID"
# Step 2: Ask multiple questions
echo -e "\nAsking questions..."
curl -X POST $BASE_URL/api/ask \
-H "Content-Type: application/json" \
-d "{\"question\": \"What time is it?\", \"user_id\": \"$USER_ID\"}"
curl -X POST $BASE_URL/api/ask \
-H "Content-Type: application/json" \
-d "{\"question\": \"Tell me about AI\", \"user_id\": \"$USER_ID\"}"
curl -X POST $BASE_URL/api/ask \
-H "Content-Type: application/json" \
-d "{\"question\": \"What is machine learning?\", \"user_id\": \"$USER_ID\"}"
# Step 3: Get conversation history
echo -e "\nFetching conversation history..."
curl -X GET "$BASE_URL/api/conversation/$USER_ID"
# Step 4: Get system stats
echo -e "\nFetching system statistics..."
curl -X GET $BASE_URL/stats
# Step 5: Get user details
echo -e "\nFetching user details..."
curl -X GET "$BASE_URL/users/$USER_ID"| Method | Endpoint | Description |
|---|---|---|
| Health & System | ||
| GET | /health |
Health check |
| GET | /ping |
Ping test |
| GET | /stats |
System statistics |
| Users | ||
| POST | /users |
Create user |
| GET | /users |
Get all users |
| GET | /users/{id} |
Get user by ID |
| PUT | /users/{id} |
Update user |
| DELETE | /users/{id} |
Delete user |
| GET | /users/{id}/questions |
Get user's questions |
| Questions | ||
| POST | /questions |
Create question record |
| GET | /questions |
Get all questions |
| GET | /questions/{id} |
Get question by ID |
| DELETE | /questions/{id} |
Delete question |
| AI Assistant | ||
| GET | /api/example-questions |
Get examples |
| POST | /api/ask |
Ask question |
| GET | /api/conversation/{id} |
Get conversation |
| GET | /api/assistant/status |
Get status |
| POST | /api/assistant/reset |
Reset assistant |
- Swagger UI: http://localhost:5000/apidocs
- OpenAPI Spec: http://localhost:5000/apispec_1.json
- Quick Start Guide: docs/SWAGGER_QUICKSTART.md
- Complete API Reference: docs/API_ENDPOINTS.md
- Models Analysis: docs/MODELS_ANALYSIS.md
For issues or questions:
- Check the Swagger UI for interactive testing
- Review the error responses for troubleshooting
- Consult the additional documentation in the
docs/folder
Last Updated: October 2, 2025
API Version: 1.0.0
Server: Flask Development Server