{
  "openapi": "3.1.0",
  "info": {
    "title": "Super Investor API",
    "description": "Limited public preview API for institutional 13F holdings, SEC Form 4 insider transactions, and stock-level aggregation. Commercial, bulk, and higher-quota access requires an API agreement. Data sourced from SEC EDGAR. Not investment advice.",
    "version": "1.0.0",
    "contact": {
      "name": "Super Investor",
      "url": "https://super-investor.com"
    },
    "license": {
      "name": "Public SEC Data",
      "url": "https://www.sec.gov/privacy#dissemination"
    }
  },
  "servers": [
    {
      "url": "https://super-investor.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/top-concentrated": {
      "get": {
        "operationId": "getHighestConvictionBets",
        "summary": "Highest conviction positions across 26 legendary investors",
        "description": "Returns stocks with the highest portfolio concentration among superinvestors (Buffett, Ackman, Pabrai, Einhorn, etc). Excludes PUT options. Sorted by max concentration percentage.",
        "responses": {
          "200": {
            "description": "List of concentrated positions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ConcentratedPosition"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/insider-transactions": {
      "get": {
        "operationId": "getInsiderTransactions",
        "summary": "Recent insider buys and sells from SEC Form 4 filings",
        "description": "Returns insider transactions (CEO, CFO, Director purchases and sales) parsed from SEC Form 4 filings. Insider purchases are one of the strongest bullish signals.",
        "parameters": [
          {
            "name": "ticker",
            "in": "query",
            "description": "Filter by stock ticker (e.g., AAPL, NVDA)",
            "schema": { "type": "string" }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by transaction type",
            "schema": { "type": "string", "enum": ["all", "purchase", "sale"], "default": "all" }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Max results (1-100)",
            "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50 }
          }
        ],
        "responses": {
          "200": {
            "description": "List of insider transactions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InsiderTransaction"
                      }
                    },
                    "count": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/fund/{cik}": {
      "get": {
        "operationId": "getFundHoldings",
        "summary": "Get all holdings for an institutional investor by CIK",
        "description": "Returns the complete portfolio for a fund, including all 13F filings and holdings. CIK is the SEC Central Index Key.",
        "parameters": [
          {
            "name": "cik",
            "in": "path",
            "required": true,
            "description": "SEC CIK number (e.g., 1067983 for Berkshire Hathaway)",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Fund details with holdings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundProfile"
                }
              }
            }
          }
        }
      }
    },
    "/api/stock/{ticker}": {
      "get": {
        "operationId": "getStockHolders",
        "summary": "Get all institutional holders of a stock",
        "description": "Returns which superinvestors hold a given stock, their position sizes, and changes over time.",
        "parameters": [
          {
            "name": "ticker",
            "in": "path",
            "required": true,
            "description": "Stock ticker symbol (e.g., AAPL, NVDA)",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Stock holders data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StockHolders"
                }
              }
            }
          }
        }
      }
    },
    "/api/search": {
      "get": {
        "operationId": "search",
        "summary": "Search for investors, funds, or stocks",
        "description": "Full-text search across investor names, fund names, CIKs, and stock tickers.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Search query",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "operationId": "getDashboardStats",
        "summary": "Platform statistics",
        "description": "Returns aggregate stats: total institutions, filings, holdings, and AUM tracked.",
        "responses": {
          "200": {
            "description": "Dashboard stats",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "institutions": { "type": "integer" },
                    "filings": { "type": "integer" },
                    "holdings": { "type": "integer" },
                    "totalAum": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ConcentratedPosition": {
        "type": "object",
        "properties": {
          "ticker": { "type": "string" },
          "issuerName": { "type": "string" },
          "maxConcentration": { "type": "number", "description": "Highest portfolio % among any investor" },
          "investorCount": { "type": "integer", "description": "Number of superinvestors holding this stock" },
          "investors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "pct": { "type": "number" }
              }
            }
          }
        }
      },
      "InsiderTransaction": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "ticker": { "type": "string" },
          "company_name": { "type": "string" },
          "insider_name": { "type": "string" },
          "insider_title": { "type": "string" },
          "is_director": { "type": "boolean" },
          "is_officer": { "type": "boolean" },
          "is_ten_percent_owner": { "type": "boolean" },
          "transaction_date": { "type": "string", "format": "date" },
          "transaction_type": { "type": "string", "enum": ["purchase", "sale"] },
          "shares": { "type": "number", "description": "Positive = bought, negative = sold" },
          "price_per_share": { "type": "number", "nullable": true },
          "total_value": { "type": "number", "nullable": true },
          "shares_owned_after": { "type": "number", "nullable": true },
          "filing_date": { "type": "string", "format": "date" }
        }
      },
      "FundProfile": {
        "type": "object",
        "properties": {
          "institution": { "type": "object" },
          "filings": { "type": "array", "items": { "type": "object" } },
          "latestHoldings": { "type": "array", "items": { "type": "object" } }
        }
      },
      "StockHolders": {
        "type": "object",
        "properties": {
          "ticker": { "type": "string" },
          "holders": { "type": "array", "items": { "type": "object" } }
        }
      }
    }
  }
}
