🔌 Interactive API Explorer
· 2 phút để đọc
Khám phá UIP API một cách tương tác! Bài viết này sử dụng MDX để tạo các ví dụ API live.
Pro Tip
Bạn có thể copy các code snippets và chạy trực tiếp với curl hoặc trong Postman!
🚀 Base URL
https://api.uip.vn/v1
# hoặc local: http://localhost:8000/api/v1
📡 Available Endpoints
- 🎥 Cameras
- 🚨 Accidents
- 🚗 Congestion
Get All Cameras
curl -X GET "http://localhost:8000/api/v1/cameras" \
-H "Accept: application/json"
Response:
{
"total": 1247,
"items": [
{
"id": "CAM001",
"name": "Nguyễn Văn Linh - Cầu Kênh Tẻ",
"location": {
"lat": 10.7352,
"lng": 106.6869
},
"status": "active",
"lastUpdate": "2025-11-29T08:30:00Z"
}
]
}
Get Recent Accidents
curl -X GET "http://localhost:8000/api/v1/accidents?limit=10" \
-H "Accept: application/json"
Response:
{
"total": 127,
"items": [
{
"id": "ACC2025112501",
"type": "vehicle_collision",
"severity": "high",
"location": {
"lat": 10.7626,
"lng": 106.6885
},
"detectedAt": "2025-11-29T07:45:00Z",
"status": "resolved"
}
]
}
Get Current Congestion
curl -X GET "http://localhost:8000/api/v1/congestion/current" \
-H "Accept: application/json"
Response:
{
"timestamp": "2025-11-29T08:30:00Z",
"hotspots": [
{
"id": "HS001",
"location": "Ngã tư Hàng Xanh",
"level": "severe",
"avgSpeed": 8,
"estimatedClearTime": "09:15:00"
}
]
}
🔐 Authentication
API sử dụng Bearer Token authentication:
curl -X GET "http://localhost:8000/api/v1/protected-endpoint" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"
Bảo mật
Không bao giờ commit API key vào source code! Sử dụng environment variables.
📊 Response Codes
| Code | Meaning |
|---|---|
200 | ✅ Success |
201 | ✅ Created |
400 | ❌ Bad Request |
401 | 🔐 Unauthorized |
404 | 🔍 Not Found |
429 | ⏱️ Rate Limited |
500 | 💥 Server Error |
🛠️ Try It Yourself
Xem full API docs tại: API Reference
Nguyễn Đình Anh Tuấn - Backend Developer @ UIP Team
