API Reference

Programmatic access to Margin Invest's scoring engine, backtesting, and institutional data.

Request an API key

Authentication

All API requests require an API key passed in the X-API-Key header. Generate and manage keys in your Account Settings.

curl -H "X-API-Key: your_api_key" \
  https://api.margin-invest.com/api/v1/scores/AAPL

Rate Limits

API requests are rate-limited per key. When you exceed the limit, responses return status 429 with a Retry-After header indicating when to retry.

  • Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
  • Limits vary by subscription plan
  • Implement exponential backoff for 429 responses

Endpoints

Scores

GET/api/v1/scores/{ticker}Composite score, factor breakdown, composite percentile
GET/api/v1/scores/{ticker}/historyHistorical score snapshots over time
GET/api/v1/scores/{ticker}/valuation-auditIntrinsic value calculation audit trail
GET/api/v1/scoresList all scored assets with current scores

Backtesting

GET/api/v1/backtest/defaultDefault backtest with current scoring parameters
POST/api/v1/backtest/replayRun custom backtest replay with parameter overrides
GET/api/v1/backtest/shadow-portfolioShadow portfolio tracking real-time picks
GET/api/v1/backtest/teaser/{ticker}Single-asset backtest teaser
GET/api/v1/backtest/portfolio-teaserPortfolio equity curve teaser (public)

Institutional (13F)

GET/api/v1/13f/holdings/{ticker}Institutional holders for a ticker from SEC 13F filings
GET/api/v1/13f/holdings/{ticker}/historyHistorical institutional holding changes
GET/api/v1/13f/managersList tracked institutional managers
GET/api/v1/13f/managers/{manager_id}/portfolioFull portfolio for a specific manager

Universe & Transparency

GET/api/v1/universe/funnelSelectivity funnel — how many assets pass each filter stage
GET/api/v1/correlations/showcaseFactor correlation matrix for scored universe
GET/api/v1/governance/transparencyOversight classification and pipeline health

Response Format & Errors

All responses are JSON. Errors return a standard shape:

{
  "detail": "Ticker not found: XYZ"
}
401Missing or invalid API key
403Insufficient subscription plan for this endpoint
404Ticker not found or no score available
429Rate limit exceeded — retry after the duration in Retry-After header
500Internal server error — contact support if persistent

SDKs & Support

The API is REST-only. Official client SDKs are not yet available.