API Reference

Complete REST API documentation for the Galedge backend. All endpoints return JSON.

Base URL: /api (relative to the application domain). Authenticated endpoints require a Bearer token in the Authorization header.

Authentication

POST/api/auth/register

Create a new user account.

Body: { "email", "password", "full_name", "organization" }

Returns: { "access_token", "token_type": "bearer" }

POST/api/auth/login

Authenticate and receive a JWT token.

Body: { "email", "password" }

Returns: { "access_token", "token_type": "bearer", "user": {...} }

Market Data

GET/api/quote/{symbol}

Get real-time quote for a single stock.

Returns: price, change, change%, volume, market cap, name, exchange

GET/api/quotes?symbols=AAPL,MSFT,GOOGL

Get quotes for multiple stocks at once.

Query: symbols — comma-separated list

GET/api/history/{symbol}

Get historical OHLCV price data.

Query params: interval (1d, 1wk, 1mo), period (1mo, 3mo, 6mo, 1y, 2y, 5y)

GET/api/technicals/{symbol}

Get technical indicators (RSI, MACD, Bollinger Bands, SMAs, EMAs).

GET/api/fundamentals/{symbol}?sheet=info

Get fundamental data (income statement, balance sheet, cash flow).

Query: sheet — info, income_stmt, balance_sheet, cashflow

GET/api/options/{symbol}?kind=calls

Get options chain data.

Query: kind (calls, puts), expiry (YYYY-MM-DD)

GET/api/intel/{symbol}?kind=all

Get intelligence data (analyst recommendations, insider trades, institutional holders, news).

Query: kind — all, recommendations, insider, institutional, mutual_fund, news

GET/api/search?q={query}

Search for stocks by name or symbol.

Analytics

All analytics endpoints require authentication.

GET/api/analytics/performance/{portfolio_id}

Get performance metrics: total return, CAGR, Sharpe, max drawdown, equity curve.

GET/api/analytics/return-decomposition/{portfolio_id}

Get factor vs idiosyncratic return decomposition.

GET/api/analytics/holdings/{portfolio_id}

Get holdings with weights, sectors, and factor exposures.

Strategies

All strategy endpoints require authentication.

GET/api/strategies/

List all user strategies (draft and production).

POST/api/strategies/

Create a new strategy with fund name, scheme, universe, constraints, and backtest config.

POST/api/strategies/{id}/promote

Promote a backtested strategy to production status.

POST/api/strategies/{id}/demote

Demote a production strategy back to draft.

POST/api/strategies/{id}/rebalance

Generate a live rebalance trade list with BUY/SELL/HOLD actions, quantities, and prices.

Optimization

POST/api/optimize/smart

Run the portfolio optimizer. Auto-computes returns and covariance from historical prices.

Body: { "universe", "objective", "constraints": [...] }

Returns: expected return, risk, Sharpe, weight allocations

POST/api/optimize/efficient-frontier

Generate the efficient frontier — set of optimal portfolios at different risk levels.

Tools

GET/api/screener

Screen stocks by fundamental criteria.

Query: sector, pe_max, div_yield_min, sort_by

GET/api/heatmap?market=us

Get market heatmap data (treemap layout).

Query: market — us or india

GET/api/compare?symbols=AAPL,MSFT&period=6mo

Compare stock performance over time.

GET/api/correlation?symbols=AAPL,MSFT&period=1y

Get Pearson correlation matrix for selected stocks.

GET/api/predict/{symbol}

Get ML prediction with signals, recommendation, and risk metrics.

Query: portfolio_value, risk_tolerance (low, medium, high)

Data & Risk Model

Data management and risk model endpoints. Require authentication.

POST/api/data/ingest/prices?market=india&period=2y

Ingest historical price data for a market.

POST/api/data/risk-model/build?model_name=INEC1

Build the factor risk model using cross-sectional regression.

GET/api/data/risk-model/factors?model_name=INEC1

Get factor summary (CAGR, Sharpe, drawdown for each factor).

GET/api/data/risk-model/correlation?model_name=INEC1

Get factor correlation matrix.