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

MethodPathDescription
GET/api/healthHealth check
GET/api/dashboard/statsDashboard statistics (packets, bytes, connections, threats, blocked)
GET/api/traffic/statsTraffic statistics
GET/api/alertsGet alerts (query: limit)
POST/api/alerts/:id/acknowledgeAcknowledge alert
DELETE/api/alerts/:idDelete alert
GET/api/threatsThreat data for map
GET/api/ml/statsML inference statistics
POST/api/monitoring/startStart packet capture
POST/api/monitoring/stopStop packet capture
POST/api/firewall/blockBlock IP (body: ip, reason)
POST/api/firewall/unblockUnblock IP (body: ip)
GET/api/firewall/blockedList 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 check
  • POST /api/license-key/validate – Validate license key

Protected Endpoints (Clerk JWT)

  • GET /api/protected/user – User data
  • POST /api/protected/license-key – Generate license key
  • POST /api/protected/download – Track download