Skip to main content

API Reference

AirSafeNet exposes two separate APIs.

AI Server — http://localhost:8000

Interactive docs: http://localhost:8000/docs

MethodEndpointAuthDescription
GET/healthService health + cache status
GET/model/infoModel version + metrics
GET/forecast/current?profile=generalCurrent PM2.5 + AQI
GET/forecast/range?days=7&profile=general7-day hourly forecast
GET/history?days=30&profile=general30-day history
GET/districts/current22-district AQI heatmap
GET/anomaly/latestLatest spike detection
GET/anomaly/historyFull anomaly log
POST/admin/compute✅ Admin keyTrigger cache recompute

Profile values: general · children · elderly · respiratory

Example Response — /forecast/current

{
"pred_pm25": 42.7,
"pred_aqi": 118,
"aqi_category": "Unhealthy for Sensitive Groups",
"risk_profile": "UNHEALTHY_SENSITIVE",
"recommendation_profile": "Nhóm nhạy cảm nên hạn chế hoạt động ngoài trời...",
"observed_pm25": 38.2,
"temperature": 32.5,
"humidity": 78.0,
"wind_speed": 3.2,
"uv_index": 7.1
}

Backend — http://localhost:7276

Swagger UI: http://localhost:7276/swagger

Auth

MethodEndpointDescription
POST/api/auth/registerCreate account
POST/api/auth/loginLogin → JWT token
GET/api/auth/meCurrent user info

Air Quality

MethodEndpointDescription
GET/api/air/currentCurrent AQI for user's group
GET/api/air/forecast?days=77-day forecast
GET/api/air/history?days=3030-day history
GET/api/air/explainWeather + AI explanation

Activity

MethodEndpointDescription
GET/api/activityList schedules
POST/api/activityCreate schedule
PUT/api/activity/{id}Update schedule
DELETE/api/activity/{id}Delete schedule
GET/api/activity/forecastRisk-scored activities for today

AI Assistant

MethodEndpointDescription
GET/api/assistant/conversationsList conversations
POST/api/assistant/chatSend message + get response
POST/api/assistant/regenerateRegenerate last response

Admin

MethodEndpointDescription
POST/api/admin/computeTrigger AI cache recompute
GET/api/admin/cache-statusCache metadata + scheduler
note

All /api/* endpoints (except /api/auth/* and /api/air/public/*) require a valid JWT token in the Authorization: Bearer <token> header.