API Reference
Overview
The EyeNet API provides programmatic access to network monitoring and management capabilities. This documentation covers all available endpoints, authentication methods, and example usage.
Authentication
All API requests require authentication using JWT (JSON Web Tokens).
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" https://api.eyenet.com/v1/metrics
Base URL
Development: http://localhost:3000/api/v1
Production: https://api.eyenet.com/v1
Endpoints
Network Metrics
Get Current Metrics
GET /metrics/current
Response:
{
"timestamp": "2025-01-25T10:30:00Z",
"metrics": {
"bandwidth": {
"download": 100.5,
"upload": 50.2
},
"latency": 15,
"packetLoss": 0.01
}
}
Get Historical Metrics
GET /metrics/historical?start={start_date}&end={end_date}
Parameters:
- start_date (ISO 8601)
- end_date (ISO 8601)
Device Management
List Devices
GET /devices
Response:
{
"devices": [
{
"id": "device_1",
"name": "Router-01",
"type": "router",
"status": "online",
"lastSeen": "2025-01-25T10:30:00Z"
}
]
}
Update Device Configuration
PUT /devices/{device_id}/config
Request Body:
{
"name": "Router-01",
"config": {
"qos": {
"bandwidth": 1000,
"priority": "high"
}
}
}
ML Predictions
Get Bandwidth Prediction
GET /ml/predict/bandwidth?horizon=6
Response:
{
"predictions": [
{
"timestamp": "2025-01-25T11:00:00Z",
"value": 120.5,
"confidence": 0.85
}
]
}
Detect Anomalies
POST /ml/detect/anomalies
Request Body:
{
"metrics": {
"bandwidth": 150.5,
"latency": 20,
"packetLoss": 0.02
}
}
Response:
{
"isAnomaly": true,
"score": 0.85,
"details": [
{
"metric": "bandwidth",
"contribution": 0.7
}
]
}
Error Handling
Error Codes
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 500: Internal Server Error
Error Response Format
{
"error": {
"code": "ERROR_CODE",
"message": "Detailed error message",
"details": {
"field": "Additional information"
}
}
}
Rate Limiting
- 1000 requests per hour per API key
- Rate limit headers included in response:
- X-RateLimit-Limit
- X-RateLimit-Remaining
- X-RateLimit-Reset
Webhooks
Available Events
- device.status.changed
- anomaly.detected
- threshold.exceeded
Webhook Format
{
"event": "device.status.changed",
"timestamp": "2025-01-25T10:30:00Z",
"data": {
"deviceId": "device_1",
"oldStatus": "online",
"newStatus": "offline"
}
}
SDKs and Client Libraries
Best Practices
-
Authentication
- Rotate JWT tokens regularly
- Use environment variables for tokens
- Implement token refresh mechanism
-
Error Handling
- Implement proper error handling
- Log API errors appropriately
- Provide meaningful error messages
-
Rate Limiting
- Implement exponential backoff
- Cache responses when possible
- Monitor rate limit headers
-
Data Handling
- Validate input data
- Handle timezone differences
- Implement proper data serialization