API Reference
Programmatic access to the Portfolio Optimization platform. Build custom integrations for Indian equities, US equities, and Indian mutual funds, automate optimization workflows, and retrieve results using our REST API.
Base URL
All API endpoints are relative to this base URL
https://api.foliolab.aiAll requests must be made over HTTPS. HTTP requests will be rejected.
Quick Navigation
Authentication Overview
Two authentication methods are supported depending on your use case
JWT Tokens
Best for web applications and interactive use. Tokens are issued via login and automatically refreshed using secure HTTP-only cookies.
API Keys
Best for server-to-server communication, scripts, and CI/CD pipelines. Scoped keys with fine-grained permissions.
See the Authentication page for complete details on sign-up, login, token refresh, API key creation, and security best practices.
Rate Limiting
Fair-use limits to ensure platform stability for all users
10 req/min20 req/min60 req/min30 req/minWhen a rate limit is exceeded, the API responds with HTTP 429 Too Many Requests. The Retry-After header indicates how many seconds to wait before retrying.
Error Response Format
All error responses follow a consistent JSON structure
When an API request fails, the response body contains a JSON object with a human-readable error message:
{
"detail": "Human-readable error message"
}HTTP Status Codes
400Bad RequestThe request body is malformed or missing required fields401UnauthorizedMissing or invalid authentication credentials403ForbiddenValid credentials but insufficient permissions for the resource404Not FoundThe requested resource does not exist409ConflictThe request conflicts with the current state (e.g., duplicate email)500Internal Server ErrorAn unexpected server-side error occurredSupported Optimization Methods
All 30 runnable methods. Pass these enum values in the methods array when submitting an optimization job
MVOClassic Markowitz mean-variance portfolio optimizationMinVolMinimize portfolio volatility regardless of returnsMaxQuadraticUtilityMaximize risk-adjusted utility with quadratic penaltyEquiWeightedUniform allocation across all selected assetsCriticalLineAlgorithmExact efficient frontier tracing via CLAHRPTree-based clustering for robust diversificationMinCVaRMinimize Conditional Value-at-Risk (expected shortfall)MinCDaRMinimize Conditional Drawdown-at-RiskHERCHierarchical Equal Risk ContributionNCONested Clustered OptimizationHERC2Enhanced Hierarchical Equal Risk ContributionBenchmarkTrackerMinimize tracking error to a benchmark indexMaximumDiversificationMaximize the portfolio diversification ratioRiskBudgetingTarget equal or custom risk contribution per assetDistributionallyRobustCVaRWorst-case CVaR over Wasserstein uncertainty setStackingOptimizationEnsemble meta-optimizer stacking multiple sub-modelsInverseVolatilityWeights inversely proportional to each asset's volatilitySparseMarkowitzL1L1-regularized Markowitz for sparse, concentrated portfoliosHMMRegimeMVOHidden Markov Model regime-switching mean-varianceBlackLittermanBlack-Litterman with market-implied equilibrium returns and momentum viewsEWMAMVOExponentially weighted moments that adapt to recent volatilityMinSemivarianceMinimize downside variance while leaving upside variation unpenalizedMinEVaRMinimize Entropic Value-at-RiskMinEDaRMinimize Entropic Drawdown-at-RiskMaxDecorrelationMinimize the portfolio correlation quadratic formRobustMVOWorst-case MVO under expected-return uncertaintyResampledMVOBootstrap-resampled MVO with averaged portfolio weightsSparseIndexTrackingTrack a benchmark with a sparse subset of assetsQuintileMomentumEqual-weight the highest-momentum asset quintileKellyLong-only growth-optimal expected log-wealth allocationExample usage in request body:
{
"stocks": [
{ "ticker": "RELIANCE", "exchange": "NSE" },
{ "ticker": "TCS", "exchange": "NSE" },
{ "ticker": "HDFCBANK", "exchange": "NSE" },
{ "ticker": "INFY", "exchange": "NSE" }
],
"methods": ["MVO", "HRP", "MinCVaR"],
"benchmark": "nifty"
}Indian requests default to the India 10-year government bond series from FRED. US requests must use a US benchmark and set risk_free.region to "US". See the Optimization API for mutual-fund and US-stock schemas, asset discovery endpoints, and complete examples.