WaiTrade API Reference.
A REST API for browsing algorithms, managing your watchlist and portfolio, and recording backtest runs. All endpoints return JSON.
Introduction
The base URL for all requests is your deployment origin — for local development, http://localhost:3000. Endpoints under /api/algorithms are public and read-only. Endpoints that read or write account data require an authenticated session and are marked Session or Admin below.
Authentication
WaiTrade uses cookie-based sessions (Auth.js). Log in via /login in the browser, or authenticate programmatically against /api/auth/callback/credentials with your email and password. The session cookie is then sent automatically on subsequent requests from the same client. There is no separate API key — session-protected endpoints check the same cookie the web app uses.
Algorithms
/api/algorithmsPublicList algorithms. Supports filtering by asset, risk, and performance thresholds.
?asset=?risk=?featured=?minReturn=?maxDrawdown=?limit={
"data": [
{
"id": "aurum-drift",
"name": "Aurum Drift",
"developer": "Halcyon Quant",
"asset": "XAUUSD",
"risk": "Low",
"returnPct": 34.2,
"maxDrawdownPct": 7.8,
"sharpe": 2.11,
"price": 249
// ...full algorithm fields
}
],
"count": 12
}/api/algorithms/:idPublicFetch a single algorithm by its id.
{
"data": {
"id": "aurum-drift",
"name": "Aurum Drift",
"equity": [1000, 1012, 998, ...]
// ...full algorithm fields
}
}Watchlist
/api/watchlistSessionList the current user's watchlist.
{ "data": [ { "algorithmId": "aurum-drift", "algorithm": { /* ... */ } } ] }/api/watchlistSessionAdd an algorithm to the current user's watchlist.
{ "algorithmId": "aurum-drift" }{ "data": { "id": "...", "algorithmId": "aurum-drift" } }/api/watchlistSessionRemove an algorithm from the current user's watchlist.
{ "algorithmId": "aurum-drift" }{ "ok": true }Portfolio
Adding an algorithm to your portfolio activates it on your dashboard with live P&L tracking. This is a platform-level activation — it does not move funds or deploy to an MT5 account.
/api/user-algorithmsSessionList the current user's active portfolio holdings.
{ "data": [ { "algorithmId": "obsidian-swing", "allocation": 34, "status": "live", "pnl": 1842.5 } ] }/api/user-algorithmsSessionAdd an algorithm to the current user's portfolio ('Get Access').
{ "algorithmId": "obsidian-swing", "allocation": 20 }{ "data": { "id": "...", "allocation": 20, "status": "live" } }/api/user-algorithmsSessionRemove an algorithm from the current user's portfolio.
{ "algorithmId": "obsidian-swing" }{ "ok": true }Backtests
/api/backtestsSessionList the current user's backtest run history, most recent first.
{ "data": [ { "algorithmName": "Obsidian Swing", "asset": "XAUUSD", "months": 24, "resultPct": 12.4 } ] }/api/backtestsSessionRecord a backtest run against the current user's history.
{
"algorithmName": "Obsidian Swing",
"algorithmId": "obsidian-swing",
"asset": "XAUUSD",
"months": 24,
"resultPct": 12.4
}{ "data": { "id": "...", "resultPct": 12.4 } }Admin
Admin endpoints require the current session's user to have the admin role. Attempting to call these without admin access returns 403.
/api/admin/usersAdminList all registered users and their subscription plan.
{ "data": [ { "id": "...", "email": "...", "role": "trader", "plan": "free" } ] }/api/admin/users/:idAdminChange a user's role. Admins cannot demote their own account.
{ "role": "developer" }{ "data": { "id": "...", "role": "developer" } }/api/admin/users/:idAdminDelete a user account. Admins cannot delete their own account here.
{ "ok": true }Errors
Errors are returned as JSON with a non-2xx status code and an error message.
{ "error": "You must be logged in." }