Complete REST API documentation for the Government Services Assistant.
Base URL: http://localhost:8000/api/v1
Currently using user_id for identification. In production, implement JWT tokens.
Send message to AI agent and get response.
Request:
{
"user_id": "string",
"session_id": "string (optional)",
"message": "string",
"language": "en|hi|ta|te",
"request_type": "string (optional)"
}Response:
{
"session_id": "string",
"response": "string",
"request_type": "string",
"links": ["string"],
"action_items": ["string"],
"warnings": ["string"]
}List available government services.
Query Parameters:
category(optional): Filter by category
Response:
{
"services": [
{
"service_id": "string",
"name": "string",
"category": "string",
"description": "string"
}
]
}Get detailed service information.
Response:
{
"service_id": "string",
"name": "string",
"category": "string",
"description": "string",
"steps": [...],
"eligibility_criteria": [...],
"document_requirements": [...],
"portal_url": "string"
}Check eligibility for a service.
Request:
{
"user_id": "string",
"service_id": "string",
"user_data": {
"age": 25,
"income": 500000,
"state": "Maharashtra"
}
}Response:
{
"eligible": true,
"met_criteria": [...],
"failed_criteria": [...],
"missing_information": [...],
"alternatives": [...]
}Upload a document with optional OCR processing.
Form Data:
file: File (required)user_id: string (required)category: string (optional)trigger_ocr: boolean (optional, default: true)
Response:
{
"document_id": "string",
"filename": "string",
"size_bytes": 123456,
"category": "string",
"ocr_task_id": "string (if OCR triggered)"
}List user's documents.
Query Parameters:
user_id(required)category(optional)limit(optional, default: 50)
Response:
{
"documents": [
{
"document_id": "string",
"filename": "string",
"category": "string",
"size_bytes": 123456,
"uploaded_at": "2024-01-01T00:00:00Z"
}
]
}Retrieve a document.
Query Parameters:
user_id(required)
Response:
{
"document_id": "string",
"filename": "string",
"content": "base64-encoded-content",
"metadata": {...}
}Delete a document.
Query Parameters:
user_id(required)
Response:
{
"message": "Document deleted successfully"
}Get OCR processing status.
Response:
{
"task_id": "string",
"status": "queued|processing|completed|failed",
"progress": 75.0,
"created_at": "2024-01-01T00:00:00Z"
}Get OCR extraction result.
Response:
{
"document_type": "aadhaar",
"fields": [
{
"field_name": "name",
"value": "John Doe",
"confidence": 0.95,
"normalized_value": "JOHN DOE"
}
],
"confidence": 0.92,
"raw_text": "..."
}Start browser automation session.
Request:
{
"user_id": "string",
"service_id": "string",
"portal_url": "string",
"workflow": {
"workflow_id": "string",
"steps": [...]
}
}Response:
{
"session_id": "string",
"status": "started",
"message": "Automation session started successfully"
}Pause automation session.
Query Parameters:
reason(optional)
Response:
{
"message": "Automation paused"
}Resume paused session.
Response:
{
"message": "Automation resumed"
}Get automation status.
Response:
{
"session_id": "string",
"status": "running|paused|completed|failed",
"current_step": 2,
"total_steps": 5,
"progress_percentage": 40.0,
"current_url": "string"
}Get automation action logs.
Query Parameters:
limit(optional, default: 50)
Response:
{
"logs": [
{
"action_id": "string",
"action_type": "navigate|fill_field|click|submit",
"timestamp": "2024-01-01T00:00:00Z",
"details": {...},
"success": true,
"error": null
}
]
}Get complete dashboard data.
Response:
{
"user_id": "string",
"active_requests": [...],
"recent_documents": [...],
"notifications": [...],
"storage_usage": {
"used_bytes": 12345678,
"total_bytes": 104857600,
"percentage": 11.8
},
"quick_links": [...],
"service_history": [...]
}Get dashboard summary statistics.
Response:
{
"active_requests": 3,
"unread_notifications": 5,
"total_documents": 12,
"storage_percentage": 11.8,
"pending_actions": 2
}Get user notifications.
Query Parameters:
unread_only(optional, default: false)
Response:
{
"notifications": [
{
"notification_id": "string",
"title": "string",
"message": "string",
"type": "info|warning|error|success",
"timestamp": "2024-01-01T00:00:00Z",
"read": false,
"action_url": "string (optional)"
}
]
}Get OAuth authorization URL.
Query Parameters:
user_id(required)scope(optional, default: "public")
Response:
{
"auth_url": "string",
"state": "string"
}Handle OAuth callback.
Request:
{
"code": "string",
"state": "string"
}Response:
{
"user_id": "string",
"expires_at": "2024-01-01T00:00:00Z",
"scope": "public"
}List documents from DigiLocker.
Query Parameters:
user_id(required)category(optional)
Response:
{
"documents": [
{
"doc_id": "string",
"doc_name": "string",
"doc_type": "string",
"issuer": "string",
"category": "string",
"size_bytes": 123456
}
]
}Import document from DigiLocker.
Query Parameters:
user_id(required)
Response:
{
"doc_id": "string",
"doc_name": "string",
"category": "string",
"imported_at": "2024-01-01T00:00:00Z",
"source": "digilocker"
}Sync documents from DigiLocker.
Query Parameters:
user_id(required)auto_import(optional, default: false)
Response:
{
"sync_id": "string"
}List available workflows.
Query Parameters:
service_id(optional)portal_url(optional)
Response:
{
"workflows": [
{
"workflow_id": "string",
"name": "string",
"description": "string",
"service_id": "string",
"portal_url": "string",
"total_steps": 4,
"estimated_duration_minutes": 15,
"required_documents": ["string"]
}
]
}Get workflow definition.
Response:
{
"workflow_id": "string",
"name": "string",
"description": "string",
"steps": [
{
"step_number": 1,
"name": "string",
"description": "string",
"page_url": "string",
"actions": [...],
"expected_elements": ["string"],
"success_indicators": ["string"]
}
],
"form_mappings": [...],
"required_documents": ["string"]
}All endpoints return errors in this format:
{
"detail": "Error message"
}Status Codes:
- 200: Success
- 400: Bad Request
- 404: Not Found
- 500: Internal Server Error
- 100 requests per minute per user
- 1000 requests per hour per user
- Exceeded limits return 429 status
Real-time updates for:
- Automation progress
- OCR processing status
- Notifications
- Dashboard updates
Endpoint: ws://localhost:8000/ws/{user_id}
import requests
# Chat with agent
response = requests.post(
'http://localhost:8000/api/v1/agent/chat',
json={
'user_id': 'user123',
'message': 'How do I change my Aadhaar name?',
'language': 'en'
}
)
print(response.json())// Upload document
const formData = new FormData();
formData.append('file', fileInput.files[0]);
const response = await fetch(
'http://localhost:8000/api/v1/documents/upload?user_id=user123',
{
method: 'POST',
body: formData
}
);
const data = await response.json();Interactive API documentation available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc