API Reference
DefenSys exposes a REST API from the desktop app and a separate Web API for the landing page and license management. Ports are configurable via your environment.
Desktop App REST API
The desktop app runs an Express server for the mobile app and external integrations. Use the host and port where the desktop app is running.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/health | Health check |
| GET | /api/dashboard/stats | Dashboard statistics (packets, bytes, connections, threats, blocked) |
| GET | /api/traffic/stats | Traffic statistics |
| GET | /api/alerts | Get alerts (query: limit) |
| POST | /api/alerts/:id/acknowledge | Acknowledge alert |
| DELETE | /api/alerts/:id | Delete alert |
| GET | /api/threats | Threat data for map |
| GET | /api/ml/stats | ML inference statistics |
| POST | /api/monitoring/start | Start packet capture |
| POST | /api/monitoring/stop | Stop packet capture |
| POST | /api/firewall/block | Block IP (body: ip, reason) |
| POST | /api/firewall/unblock | Unblock IP (body: ip) |
| GET | /api/firewall/blocked | List blocked IPs |
Security
- Helmet.js for security headers
- CORS enabled (configurable origins)
- Rate limiting: 100 requests per 15 minutes per IP
Middleware (Code)
// backend/api/server.js - setupMiddleware()
this.app.use(helmet());
this.app.use(cors({ origin: "*", methods: ["GET","POST","PUT","DELETE"] }));
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 min
max: 100,
message: "Too many requests from this IP",
});
this.app.use(limiter);Web API
The Web API serves the landing page, license keys, and protected endpoints. Configure the base URL in your environment.
Public Endpoints
GET /health– Health checkPOST /api/license-key/validate– Validate license key
Protected Endpoints (Clerk JWT)
GET /api/protected/user– User dataPOST /api/protected/license-key– Generate license keyPOST /api/protected/download– Track download