Skip to main content

API Reference Overview

FLOPY-NET provides REST APIs for its core components, enabling programmatic access to federated learning orchestration, network management, policy enforcement, and real-time monitoring.

API Architecture

Service Endpoints

Core Services

ServicePortBase URLDescriptionStatus
Policy Engine API5000/Policy management and enforcement✅ Active
Collector API8000/Metrics collection and aggregation✅ Active
FL Server API8080/8081/Federated learning coordination✅ Active
SDN Controller API8181/onos/v1Network management (if enabled)🔶 Optional

Network Configuration

All services run on the 192.168.100.0/24 network with static IPs:

ServiceContainer IPExternal PortInternal Port
Policy Engine192.168.100.2050005000
Collector192.168.100.4080008000
FL Server192.168.100.10-8080/8081
SDN Controller192.168.100.41-6633/8181

Authentication

All APIs use JWT-based authentication with the following header:

Authorization: Bearer <jwt_token>

Rate Limiting

APIs implement rate limiting to ensure fair usage:

  • Dashboard API: 1000 requests/hour per IP
  • Collector API: 5000 requests/hour per IP
  • Policy Engine API: 500 requests/hour per IP
  • FL Server API: 100 requests/hour per IP
  • SDN Controller API: 200 requests/hour per IP

Error Handling

All APIs return consistent error responses:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": {
"field": "client_id",
"issue": "Required field missing"
},
"timestamp": "2024-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}

Common HTTP Status Codes

CodeDescriptionUsage
200OKSuccessful GET, PUT, PATCH
201CreatedSuccessful POST
204No ContentSuccessful DELETE
400Bad RequestInvalid request parameters
401UnauthorizedMissing or invalid authentication
403ForbiddenInsufficient permissions
404Not FoundResource not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side error

WebSocket Connections

Real-time data streaming is available through WebSocket connections:

// Connect to real-time metrics
const ws = new WebSocket('ws://localhost:8081/ws/metrics');

ws.onmessage = function(event) {
const data = JSON.parse(event.data);
console.log('Real-time metrics:', data);
};

WebSocket Endpoints

EndpointDescription
/ws/metricsReal-time metrics streaming
/ws/fl-statusFL training status updates
/ws/network-eventsNetwork topology changes
/ws/policy-eventsPolicy enforcement events

API Versioning

APIs follow semantic versioning with backwards compatibility:

  • v1: Current stable version
  • v2: Beta version with new features
  • v3: Alpha version for experimental features

Version is specified in the URL path: /api/v1/...

SDKs and Client Libraries

Official client libraries are available:

  • Python SDK: pip install flopy-net-client
  • JavaScript SDK: npm install flopy-net-client
  • Go SDK: go get github.com/flopy-net/go-client

Interactive API Explorer

Use the built-in API explorer to test endpoints:

# Start the API documentation server
cd docs
npm run api-docs

# Open http://localhost:3000/api-explorer

Next Steps