API Reference - Endpoints¶
Complete reference for all AirChain API endpoints.
Base URL¶
https://api.airchain.ng/v1
Authentication¶
All requests require Bearer token: Authorization: Bearer YOUR_API_KEY
GET /sensors¶
List all active sensors.
Query Parameters:
- status - Filter by status (online, offline)
- area - Filter by Lagos area
- limit - Max results (default: 100)
Example:
curl "https://api.airchain.ng/v1/sensors?area=Yaba" \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"status": "success",
"count": 25,
"sensors": [
{
"id": "NGR-LOS-YAB-001",
"location": {"lat": 6.5244, "lon": 3.3792, "address": "Yaba, Lagos"},
"status": "online",
"last_reading": "2025-11-29T14:35:00Z",
"uptime_24h": 0.98
}
]
}
GET /readings¶
Get latest air quality readings.
Query Parameters:
- sensor_id - Specific sensor
- limit - Max results (default: 10)
- start_time / end_time - Time range (ISO8601)
Example:
curl "https://api.airchain.ng/v1/readings?sensor_id=NGR-LOS-YAB-001&limit=5" \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"status": "success",
"readings": [
{
"timestamp": "2025-11-29T14:35:00Z",
"measurements": {
"pm25": 45.3,
"pm10": 78.2,
"co2": 420,
"temperature": 28.5,
"humidity": 72
},
"aqi": 112,
"aqi_category": "unhealthy_sensitive",
"blockchain": {
"hash": "8a4f2b9c...",
"verified": true
}
}
]
}
GET /readings/{sensor_id}/verify¶
Cryptographically verify a reading.
Query Parameters:
- timestamp - Reading timestamp (ISO8601)
Example:
curl "https://api.airchain.ng/v1/readings/NGR-LOS-YAB-001/verify?timestamp=2025-11-29T14:35:00Z" \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"status": "verified",
"merkle_proof": {
"root": "d5e3a1b8...",
"path": ["7f9b2d4c...", "a1f3b5d7..."]
},
"cardano": {
"tx_hash": "a3b2c1d4...",
"explorer_url": "https://cardanoscan.io/transaction/..."
}
}
GET /areas/{area_name}¶
Get aggregated statistics for a Lagos area.
Example:
curl "https://api.airchain.ng/v1/areas/Yaba" \
-H "Authorization: Bearer YOUR_API_KEY"