Spaces:
Sleeping

edi.chat.test / docs /API_REFERENCE.md
Claude Code Bot
Claude
Deploy edi.chat UGA AI Assistant to Hugging Face Spaces
0b355ec
|
Raw History Blame Contribute Delete
9.9 kB

API Reference

Overview

The UGA Agentic AI Chatbot API provides comprehensive endpoints for managing conversations, user authentication, student services, and faculty operations. All API endpoints follow RESTful conventions and return JSON responses.

Base URL: http://localhost:5000/api (development)

Authentication

All protected endpoints require a valid JWT token in the Authorization header:

Authorization: Bearer <token>

Login Flow

  1. Standard Login: POST /auth/login
  2. MyID Login: POST /auth/myid-login
  3. Token Refresh: POST /auth/refresh
  4. Logout: POST /auth/logout

Response Format

All API responses follow this standard format:

{
  "success": boolean,
  "data": any,
  "message": string,
  "error": string
}

Endpoints

Authentication (/api/auth)

POST /auth/login

Standard username/password authentication.

Request Body:

{
  "username": "string",
  "password": "string"
}

Response:

{
  "success": true,
  "data": {
    "token": "jwt_token",
    "refreshToken": "refresh_token",
    "user": {
      "id": "user_id",
      "email": "user@uga.edu",
      "firstName": "First",
      "lastName": "Last",
      "role": "student|faculty|admin"
    }
  }
}

POST /auth/myid-login

UGA MyID system authentication.

Request Body:

{
  "username": "string",
  "password": "string"
}

GET /auth/me

Get current authenticated user information.

Headers: Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": {
    "id": "user_id",
    "ugaId": "811123456",
    "email": "user@uga.edu",
    "firstName": "First",
    "lastName": "Last",
    "role": "student",
    "classification": "Senior",
    "major": "Computer Science",
    "college": "Franklin College of Arts and Sciences"
  }
}

Chat (/api/chat)

GET /chat/conversations

List all conversations for the authenticated user.

Query Parameters:

  • limit (optional): Number of conversations to return (default: 50)
  • offset (optional): Pagination offset (default: 0)
  • category (optional): Filter by category

Response:

{
  "success": true,
  "data": [
    {
      "id": "conversation_id",
      "title": "Course Registration Help",
      "category": "academics",
      "lastActivity": "2024-03-15T10:30:00Z",
      "messageCount": 12
    }
  ]
}

POST /chat/conversations

Create a new conversation.

Request Body:

{
  "title": "string (optional)",
  "category": "string (optional)"
}

GET /chat/conversations/:id

Get conversation details including message history.

Response:

{
  "success": true,
  "data": {
    "id": "conversation_id",
    "title": "Course Registration Help",
    "messages": [
      {
        "id": "message_id",
        "role": "user|assistant",
        "content": "Message content",
        "timestamp": "2024-03-15T10:30:00Z",
        "metadata": {
          "ugaSystemUsed": "Athena",
          "intent": "course_registration",
          "agentic": true,
          "executionResults": [
            {
              "action": "register_course",
              "success": true,
              "message": "Successfully registered for CSCI 1301"
            }
          ]
        }
      }
    ]
  }
}

POST /chat/message

Send a message to the chatbot.

Request Body:

{
  "conversationId": "conversation_id (optional)",
  "message": "How do I register for CSCI 1301?",
  "metadata": {
    "location": "string (optional)",
    "context": "object (optional)"
  }
}

Response:

{
  "success": true,
  "data": {
    "userMessage": {
      "id": "message_id",
      "role": "user",
      "content": "How do I register for CSCI 1301?",
      "timestamp": "2024-03-15T10:30:00Z"
    },
    "assistantMessage": {
      "id": "message_id",
      "role": "assistant",
      "content": "I can help you register for CSCI 1301...",
      "timestamp": "2024-03-15T10:30:05Z",
      "metadata": {
        "ugaSystemUsed": "Athena",
        "intent": "course_registration",
        "agentic": true
      }
    },
    "conversationId": "conversation_id"
  }
}

User Management (/api/users)

GET /users/stats

Get user activity statistics.

Response:

{
  "success": true,
  "data": {
    "totalConversations": 15,
    "totalQuestions": 127,
    "favoriteTopics": ["academics", "dining", "housing"],
    "averageResponseTime": 1.2,
    "lastActive": "2024-03-15T10:30:00Z"
  }
}

PUT /users/profile

Update user profile information.

Request Body:

{
  "firstName": "string (optional)",
  "lastName": "string (optional)",
  "email": "string (optional)",
  "phone": "string (optional)",
  "address": "string (optional)"
}

GET /users/conversations/summary

Get conversation summary for dashboard.

Query Parameters:

  • limit: Number of recent conversations (default: 5)

Student Services (/api/students)

GET /students/courses

Get enrolled and available courses.

Response:

{
  "success": true,
  "data": {
    "enrolled": [
      {
        "id": "course_id",
        "code": "CSCI 1301",
        "title": "Introduction to Computing and Programming",
        "credits": 4,
        "instructor": "Dr. Smith",
        "schedule": "MWF 10:10-11:00",
        "location": "Boyd GSRC 303"
      }
    ],
    "available": [
      {
        "id": "course_id",
        "code": "CSCI 2720",
        "title": "Data Structures",
        "credits": 4,
        "instructor": "Dr. Johnson",
        "schedule": "TR 2:00-3:15",
        "location": "Boyd GSRC 304",
        "enrolled": 45,
        "capacity": 50,
        "waitlist": 3
      }
    ]
  }
}

POST /students/courses/register

Register for a course.

Request Body:

{
  "courseId": "course_id"
}

DELETE /students/courses/:courseId

Drop a course.

GET /students/financial

Get financial information.

Response:

{
  "success": true,
  "data": {
    "balance": 2500.00,
    "dueDate": "2024-04-15",
    "aid": [
      {
        "type": "HOPE Scholarship",
        "amount": 4000.00,
        "status": "Awarded"
      }
    ],
    "paymentHistory": []
  }
}

GET /students/housing

Get housing information.

GET /students/meals

Get meal plan information.

Faculty Services (/api/faculty)

GET /faculty/dashboard

Get faculty dashboard data.

Response:

{
  "success": true,
  "data": {
    "summary": {
      "totalCourses": 3,
      "totalStudents": 150,
      "pendingGrades": 23,
      "unreadMessages": 5
    },
    "courses": [
      {
        "id": "course_id",
        "name": "CSCI 1301",
        "section": "001",
        "semester": "Spring 2024",
        "enrollment": 50,
        "nextDeadline": "Midterm Grades Due - March 20"
      }
    ],
    "notifications": [
      {
        "message": "Grade submission deadline approaching",
        "type": "deadline",
        "priority": "high"
      }
    ]
  }
}

GET /faculty/courses

List faculty courses.

GET /faculty/analytics

Get student performance analytics.

Query Parameters:

  • courseId (optional): Filter by specific course

Response:

{
  "success": true,
  "data": {
    "totalStudents": 127,
    "averageGrade": 84.2,
    "pendingGrades": 23,
    "atRiskStudents": 8,
    "gradeDistribution": [
      { "grade": "A", "count": 15, "percentage": 30 },
      { "grade": "B", "count": 20, "percentage": 40 }
    ],
    "attendanceData": [],
    "performanceData": []
  }
}

POST /faculty/grades

Submit grades for students.

Knowledge Base (/api/knowledge)

GET /knowledge/search

Search knowledge base articles.

Query Parameters:

  • q: Search query
  • category (optional): Filter by category
  • limit (optional): Number of results

GET /knowledge/articles/:id

Get specific article details.

POST /knowledge/articles/:id/bookmark

Toggle bookmark status for an article.

Settings (/api/settings)

GET /settings

Get user settings and preferences.

PUT /settings

Update user settings.

WebSocket Events

The chat system supports real-time communication via WebSocket:

Client to Server Events

  • join_conversation: Join a conversation room
  • leave_conversation: Leave a conversation room
  • typing_start: User started typing
  • typing_stop: User stopped typing

Server to Client Events

  • message_received: New message in conversation
  • typing_indicator: Someone is typing
  • conversation_updated: Conversation metadata changed
  • user_joined: User joined conversation
  • user_left: User left conversation

Error Codes

  • 400 - Bad Request (validation errors)
  • 401 - Unauthorized (authentication required)
  • 403 - Forbidden (insufficient permissions)
  • 404 - Not Found (resource doesn't exist)
  • 429 - Too Many Requests (rate limit exceeded)
  • 500 - Internal Server Error

Rate Limits

  • Authentication endpoints: 5 requests per minute
  • Chat endpoints: 30 requests per minute
  • General API: 100 requests per minute
  • File upload: 10 requests per minute

SDKs and Examples

JavaScript/TypeScript

import { ChatAPI } from './services/api';

// Send a message
const response = await ChatAPI.sendMessage('conv_id', 'Hello!');
console.log(response.data.assistantMessage.content);

// Get conversations
const conversations = await ChatAPI.getConversations();

cURL Examples

# Login
curl -X POST http://localhost:5000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "test@uga.edu", "password": "password"}'

# Send message
curl -X POST http://localhost:5000/api/chat/message \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are the library hours?"}'