How Barfinex Works
Detector API reference
REST API of the Barfinex Detector: detector selection, health, state, options, accounts, trades, performance, plugins, and risk close-position.
Overview
The Detector is the signal engine. Its REST API is used to select the active detector, read state and performance, manage plugins, and request position closure for risk.
- Base URL when called via Provider:
GET|POST /api/detectors/:appKey/...(e.g.appKey=detector) - Direct base URL:
{detectorUrl}/api(default port 8101)
All paths below are relative to /api. When using the Provider proxy, the path becomes /api/detectors/:appKey/detector/... or /api/detectors/:appKey/risk/... as in the table.
REST endpoints (summary)
| Method | Path (on Detector) | Description |
|---|---|---|
| GET | /detector/select | Switch active detector (query: sysName) |
| GET | /detector/active | Get active detector |
| GET | /detector/health | Health check and readiness |
| GET | /detector/state | Full state (options, performance, timestamp) |
| GET | /detector/options | Current and previous detector options |
| GET | /detector/accounts | Detector accounts |
| GET | /detector/trades/last | Last trades by symbol |
| GET | /detector/performance | Performance metrics of active detector |
| POST | /detector/plugins/:studioGuid/install | Install plugin |
| GET | /detector/plugins/installed | List installed plugins |
| GET | /detector/plugins/:studioGuid | Plugin details |
| POST | /risk/close-position | Close position for risk (body: symbol, connectorType, marketType, side?, quantity?, reason) |
Via Provider proxy
| Resource | Example Provider path |
|---|---|
| Select detector | GET /api/detectors/:appKey/detector/select?sysName=... |
| Active detector | GET /api/detectors/:appKey/detector/active |
| Health | GET /api/detectors/:appKey/detector/health |
| State | GET /api/detectors/:appKey/detector/state |
| Options | GET /api/detectors/:appKey/detector/options |
| Accounts | GET /api/detectors/:appKey/detector/accounts |
| Last trades | GET /api/detectors/:appKey/detector/trades/last |
| Performance | GET /api/detectors/:appKey/detector/performance |
| Plugins | POST /api/detectors/:appKey/detector/plugins/:studioGuid/install, GET .../plugins/installed, GET .../plugins/:studioGuid |
| Close position | POST /api/detectors/:appKey/risk/close-position |
Plugin endpoints may require authentication (e.g. user context). Risk close-position request body includes symbol, connectorType, marketType, optional side, quantity, and reason; response includes success, optional orderId, symbol, side, closedQuantity, or error message.
Events (for integrators)
The Detector consumes market and account events from the event bus (from Provider) and risk events (from Inspector). It publishes signal and position-request events. For real-time data in your app, use the Provider WebSocket (/ws); you do not need to connect to the Detector or the bus directly. Subscribe to events such as DETECTOR_SIGNAL_GENERATED, DETECTOR_SIGNAL_UPDATED, DETECTOR_SIGNAL_INVALIDATED, and position request events.
Next steps
- Provider API reference — Proxy and WebSocket
- Building with the API — Single gateway pattern