{
  "openapi": "3.1.0",
  "info": {
    "title": "Shumi API",
    "description": "Market data, verdicts and plain-word answers for crypto and real-world assets. Data routes return a versioned envelope that holds either `data` or `error`.\n\nThe `shumi` CLI and the `@shumi-ai/mcp` MCP server call the same routes.",
    "version": "1.0.0"
  },
  "servers": [
    { "url": "https://api.shumi.ai", "description": "Production" }
  ],
  "security": [{ "bearerAuth": [] }],
  "tags": [
    { "name": "Ask", "description": "Questions in plain words, answered by Shumi." },
    { "name": "Coins", "description": "Single-asset lookup, risk context, sentiment, and history." },
    { "name": "Market", "description": "Market-wide prices, breadth, and baselines." },
    { "name": "Categories", "description": "Category listings, membership, and sentiment." },
    { "name": "Sentiment", "description": "Crowd sentiment and narrative momentum." },
    { "name": "Trade decisions", "description": "Regime, funding, futures, pairs, and per-coin verdicts." },
    { "name": "Unlocks", "description": "Scheduled token unlocks for one coin or across the market." },
    { "name": "Tracking", "description": "Watched holders, wallets, baskets, and transcripts." },
    { "name": "RWA", "description": "Real-world assets that trade as perps: stocks, ETFs, metals, commodities, indices and FX." },
    { "name": "Streaming", "description": "Live NDJSON streams." },
    { "name": "Account", "description": "Your plan." }
  ],
  "paths": {
    "/api/cli": {
      "post": {
        "operationId": "ask",
        "summary": "Ask a natural-language question",
        "description": "Answers a question in plain words. Shumi picks the data the question needs, fetches it and writes the answer. Paid per call, it costs 0.05 USDC. Without a key, you can usually try one question from these docs.\n\nThe answer comes back as one JSON object with `text` and `steps`. This route does not use the standard envelope: its errors are a bare `{ \"error\": \"...\" }` object.",
        "tags": ["Ask"],
        "security": [{ "bearerAuth": [] }, {}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["messages"],
                "properties": {
                  "messages": {
                    "type": "array",
                    "description": "Conversation history. The last message must have role `user`.",
                    "items": {
                      "type": "object",
                      "required": ["role", "content"],
                      "properties": {
                        "role": { "type": "string", "enum": ["user", "assistant"] },
                        "content": { "type": "string" }
                      }
                    }
                  },
                  "raw": { "type": "boolean", "default": false, "description": "Return only `steps`, the data Shumi fetched, without a written answer." }
                }
              },
              "examples": {
                "simple": {
                  "summary": "One-shot question",
                  "value": { "messages": [{ "role": "user", "content": "Is BTC funding crowded right now?" }] }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "text": { "type": "string", "description": "The written answer. Absent when `raw` is true." },
                    "steps": { "type": "array", "description": "The data Shumi fetched to answer.", "items": {} }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/PlainError" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "401": { "$ref": "#/components/responses/PlainError" },
          "403": { "$ref": "#/components/responses/PlainError" },
          "429": { "$ref": "#/components/responses/PlainError" },
          "500": { "$ref": "#/components/responses/PlainError" },
          "502": { "$ref": "#/components/responses/PlainError" },
          "503": { "$ref": "#/components/responses/PlainError" }
        }
      }
    },
    "/api/cli/signal/{symbol}": {
      "get": {
        "operationId": "getSignal",
        "summary": "Verdict for one coin",
        "description": "A verdict for one coin, with its evidence. `coverage` (`high`, `medium` or `low`) says how many of the four inputs (trend, funding, sentiment, regime) answered. `confidence` carries the same value.",
        "tags": ["Trade decisions"],
        "parameters": [{ "$ref": "#/components/parameters/SymbolPath" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "401": { "$ref": "#/components/responses/Unauthorized" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/resolve": {
      "get": {
        "operationId": "resolve",
        "summary": "Resolve free text to an asset",
        "description": "Searches coins and real-world assets and returns ranked matches, each tagged with how it was found. Use it for a ticker that names both a coin and a real-world asset, such as `GOLD` or `COIN`.",
        "tags": ["Coins"],
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Ticker, name, or contract address.", "example": "GOLD" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 5 } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/lookup": {
      "get": {
        "operationId": "coinLookup",
        "summary": "Look up a coin by ticker",
        "description": "Returns coin metadata and trend state. If the ticker also matches a real-world asset, the response carries a `note` naming the collision.",
        "tags": ["Coins"],
        "parameters": [{ "name": "symbol", "in": "query", "required": true, "schema": { "type": "string" }, "example": "BTC" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/risk/{symbol}": {
      "get": {
        "operationId": "getCoinRisk",
        "summary": "Bundled risk context",
        "description": "Price, funding, trend alignment, sentiment stance, and BTC correlation in one payload. Fields that could not be refreshed are listed in `_stale_fields`.",
        "tags": ["Coins"],
        "parameters": [{ "$ref": "#/components/parameters/SymbolPath" }],
        "responses": {
          "200": {
            "description": "Risk context.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Envelope" },
                "example": {
                  "schemaVersion": 1,
                  "data": { "symbol": "BTC", "price": 67234.12, "funding_apr": 0.0421, "trend_daily": "UP", "trend_weekly": "UP", "sentiment_stance": "bullish", "btc_correlation": 1.0 },
                  "meta": { "ts": "2026-08-11T15:22:43.000Z", "as_of": "2026-08-11T15:20:00.000Z", "data_age_seconds": 163 }
                }
              }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/cli/coin/sentiment/{symbol}": {
      "get": {
        "operationId": "getCoinSentiment",
        "summary": "Crowd sentiment for one coin",
        "tags": ["Coins"],
        "parameters": [{ "$ref": "#/components/parameters/SymbolPath" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/historical/{symbol}": {
      "get": {
        "operationId": "getCoinHistorical",
        "summary": "Historical metadata",
        "tags": ["Coins"],
        "parameters": [
          { "$ref": "#/components/parameters/SymbolPath" },
          { "name": "amount", "in": "query", "schema": { "type": "integer", "default": 24 }, "description": "How many intervals back." },
          { "name": "interval", "in": "query", "schema": { "type": "string", "enum": ["h", "d"], "default": "h" } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/by-contract/{address}": {
      "get": {
        "operationId": "getCoinByContract",
        "summary": "Resolve a contract address to a coin",
        "tags": ["Coins"],
        "parameters": [
          { "name": "address", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "chain", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Chain slug. Required.", "example": "ethereum" }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/by-id/{id}": {
      "get": {
        "operationId": "getCoinById",
        "summary": "Coin by canonical id",
        "tags": ["Coins"],
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "example": "bitcoin" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/coin/by-name/{name}": {
      "get": {
        "operationId": "getCoinByName",
        "summary": "Coin by display name",
        "tags": ["Coins"],
        "parameters": [{ "name": "name", "in": "path", "required": true, "schema": { "type": "string" }, "example": "Bitcoin" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/market/prices": {
      "get": {
        "operationId": "getMarketPrices",
        "summary": "Live prices",
        "description": "Keyed by ticker.",
        "tags": ["Market"],
        "parameters": [
          { "name": "symbols", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Comma-separated uppercase tickers.", "example": "BTC,ETH" },
          { "name": "baselines", "in": "query", "schema": { "type": "boolean" }, "description": "Also return 4h/24h/7d baselines." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/market/global": {
      "get": { "operationId": "getMarketGlobal", "summary": "Global market snapshot", "tags": ["Market"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/market/crossing": {
      "get": {
        "operationId": "getMarketCrossing",
        "summary": "Breadth crossings",
        "description": "Returns a `crossings` array, empty when nothing has fired.",
        "tags": ["Market"],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/market/health": {
      "get": {
        "operationId": "getMarketHealth",
        "summary": "Market breadth and health",
        "tags": ["Market"],
        "parameters": [{ "name": "context", "in": "query", "schema": { "type": "boolean" }, "description": "Return the richer interpreted context instead of raw breadth." }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/market/baselines": {
      "get": {
        "operationId": "getMarketBaselines",
        "summary": "Reference baselines",
        "tags": ["Market"],
        "parameters": [
          { "name": "horizons", "in": "query", "schema": { "type": "string", "default": "4h,24h,7d" } },
          { "name": "symbols", "in": "query", "schema": { "type": "string" }, "description": "Comma-separated tickers. Omit for market-wide." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/category/list": {
      "get": { "operationId": "listCategories", "summary": "All categories", "tags": ["Categories"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/category/info/{name}": {
      "get": { "operationId": "getCategory", "summary": "Category trend breakdown", "tags": ["Categories"], "parameters": [{ "$ref": "#/components/parameters/CategoryPath" }], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/category/coins/{name}": {
      "get": { "operationId": "getCategoryCoins", "summary": "Coins in a category", "tags": ["Categories"], "parameters": [{ "$ref": "#/components/parameters/CategoryPath" }], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/category/sentiment/{name}": {
      "get": { "operationId": "getCategorySentiment", "summary": "Sentiment for a category", "tags": ["Categories"], "parameters": [{ "$ref": "#/components/parameters/CategoryPath" }], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/sentiment": {
      "get": {
        "operationId": "getSentiment",
        "summary": "Sentiment and narrative momentum",
        "tags": ["Sentiment"],
        "parameters": [
          {
            "name": "action", "in": "query",
            "schema": { "type": "string", "enum": ["latest", "market", "summary", "narratives", "categories", "health", "slopes", "entity-slopes", "coin", "category", "narrative"], "default": "market" },
            "description": "`slopes` and `entity-slopes` return narrative momentum rather than sentiment level."
          },
          { "name": "symbol", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=coin`." },
          { "name": "name", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=category` or `action=narrative`." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/narratives": {
      "get": { "operationId": "getNarratives", "summary": "Active narratives", "tags": ["Sentiment"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/regime": {
      "get": {
        "operationId": "getRegime",
        "summary": "Market regime",
        "tags": ["Trade decisions"],
        "parameters": [
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["active", "signals", "confidence", "history"], "default": "active" } },
          { "name": "symbol", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=history`." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/funding/momentum": {
      "get": {
        "operationId": "getFundingMomentum",
        "summary": "Perpetual funding momentum",
        "description": "Market-wide when `symbol` is omitted, otherwise scoped to one asset.",
        "tags": ["Trade decisions"],
        "parameters": [{ "name": "symbol", "in": "query", "schema": { "type": "string" }, "example": "BTC" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/funding/alerts": {
      "get": { "operationId": "getFundingAlerts", "summary": "Recent funding alert events", "tags": ["Trade decisions"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/futures": {
      "get": {
        "operationId": "getFutures",
        "summary": "Futures signals",
        "tags": ["Trade decisions"],
        "parameters": [
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["state", "log", "history"], "default": "state" }, "description": "`state` is currently open signals; `log` is recent fires across assets." },
          { "name": "asset", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=history`." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/pairs": {
      "get": {
        "operationId": "getPairs",
        "summary": "Pair trading and delta-neutral",
        "description": "`suggestions` pairs two different coins. `delta-neutral` is the same coin across two venues, earning the funding spread. They are not interchangeable.",
        "tags": ["Trade decisions"],
        "parameters": [
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["suggestions", "history", "signal", "delta-neutral"], "default": "suggestions" } },
          { "name": "tokenA", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=signal`.", "example": "eth" },
          { "name": "tokenB", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=signal`.", "example": "sol" }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/trends": {
      "get": {
        "operationId": "getTrends",
        "summary": "Trend state across the market",
        "tags": ["Trade decisions"],
        "parameters": [{ "name": "action", "in": "query", "schema": { "type": "string", "enum": ["fresh", "stale", "aligned", "extreme", "historical"], "default": "fresh" } }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/walkforward": {
      "get": {
        "operationId": "getWalkforward",
        "summary": "Signal track record",
        "description": "The forward-tested record of Shumi's signals: the signals, the positions they opened and their outcomes.",
        "tags": ["Trade decisions"],
        "parameters": [{ "name": "action", "in": "query", "schema": { "type": "string", "enum": ["signals", "positions", "outcomes"], "default": "signals" } }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/scan": {
      "get": {
        "operationId": "scan",
        "summary": "Filterable market screener",
        "tags": ["Market"],
        "parameters": [
          { "name": "trend", "in": "query", "schema": { "type": "string", "enum": ["UP", "HODL", "DOWN"] } },
          { "name": "category", "in": "query", "schema": { "type": "string" }, "description": "One category name from `/api/cli/category/list`.", "example": "Meme" },
          { "name": "mcap_min", "in": "query", "schema": { "type": "number" }, "description": "Minimum market cap in US dollars." },
          { "name": "mcap_max", "in": "query", "schema": { "type": "number" }, "description": "Maximum market cap in US dollars." },
          { "name": "interval", "in": "query", "schema": { "type": "string", "enum": ["1d", "1w"], "default": "1d" }, "description": "Daily or weekly trend." },
          { "name": "sortBy", "in": "query", "schema": { "type": "string", "enum": ["marketCap", "change24h", "change7d", "price", "streak"], "default": "marketCap" }, "description": "`change24h` ranks the day's movers." },
          { "name": "sortOrder", "in": "query", "schema": { "type": "string", "enum": ["asc", "desc"], "default": "desc" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/signal-quality": {
      "get": { "operationId": "getSignalQuality", "summary": "Signal quality scoring", "tags": ["Trade decisions"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/holders": {
      "get": {
        "operationId": "getHolders",
        "summary": "Tracked token holder counts",
        "tags": ["Tracking"],
        "parameters": [
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["watchlist", "movements"], "default": "watchlist" } },
          { "name": "contract", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=movements`." },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/wallets": {
      "get": {
        "operationId": "getWallets",
        "summary": "Tracked wallet activity",
        "tags": ["Tracking"],
        "parameters": [
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["watchlist", "movements"], "default": "watchlist" } },
          { "name": "address", "in": "query", "schema": { "type": "string" }, "description": "Required when `action=movements`." },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/transcripts": {
      "get": {
        "operationId": "getTranscripts",
        "summary": "Highlights mined from tracked transcripts",
        "description": "Spoken-word commentary from tracked video and podcast sources, tagged with the coins, sectors, and macro topics mentioned.",
        "tags": ["Tracking"],
        "parameters": [{ "name": "action", "in": "query", "schema": { "type": "string", "enum": ["highlights", "sources"], "default": "highlights" } }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "400": { "$ref": "#/components/responses/BadRequest" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/basket": {
      "get": { "operationId": "getBasket", "summary": "Tracked basket snapshots", "tags": ["Tracking"], "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } } }
    },
    "/api/cli/unlocks/{symbol}": {
      "get": {
        "operationId": "getUnlocks",
        "summary": "Token unlocks for one coin",
        "description": "The next unlock: date, tokens, US dollar value, share of market cap and recipients. Also what releases over the next 30 and 90 days, how much is unlocked so far, and how price moved in the 7 days around past unlocks. `state` is `upcoming`, `fully_unlocked`, `no_unlock_data` or `not_covered`. Every figure carries its source link.",
        "tags": ["Unlocks"],
        "parameters": [
          { "name": "symbol", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Coin ticker.", "example": "ARB" },
          { "name": "coinId", "in": "query", "schema": { "type": "string" }, "description": "Coin id. Wins over the ticker when several coins share it.", "example": "arbitrum" }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/unlocks/calendar": {
      "get": {
        "operationId": "getUnlockCalendar",
        "summary": "Upcoming unlocks across the market",
        "description": "Each row has the date, coin, tokens, US dollar value, share of market cap, recipients and the team and investor share. Ranked by share of market cap unless `sort` says otherwise.",
        "tags": ["Unlocks"],
        "parameters": [
          { "name": "days", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 30, "default": 7 }, "description": "Window in days from today." },
          { "name": "maxRank", "in": "query", "schema": { "type": "integer", "minimum": 10, "maximum": 5000, "default": 500 }, "description": "Only coins up to this market-cap rank." },
          { "name": "minPct", "in": "query", "schema": { "type": "number", "minimum": 0.5, "default": 0.5 }, "description": "Smallest unlock to include, in % of market cap." },
          { "name": "sort", "in": "query", "schema": { "type": "string", "enum": ["pct", "usd", "date"], "default": "pct" }, "description": "`pct` by share of market cap, `usd` by dollar value, `date` soonest first." },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 50, "default": 15 } },
          { "name": "insidersOnly", "in": "query", "schema": { "type": "boolean", "default": false }, "description": "Only unlocks with a team or investor share." }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/rwa/assets": {
      "get": {
        "operationId": "listRwaAssets",
        "summary": "List real-world assets",
        "description": "Stocks, ETFs, metals, commodities, indices and FX that trade as perps.",
        "tags": ["RWA"],
        "parameters": [
          { "name": "type", "in": "query", "schema": { "type": "string" }, "description": "Filter by asset class." },
          { "name": "dex", "in": "query", "schema": { "type": "string" }, "description": "Filter by venue." },
          { "name": "top", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/rwa/asset/{id}": {
      "get": {
        "operationId": "getRwaAsset",
        "summary": "One real-world asset",
        "tags": ["RWA"],
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Namespaced id.", "example": "xyz:AAPL" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/rwa/symbol/{symbol}": {
      "get": {
        "operationId": "getRwaBySymbol",
        "summary": "Real-world asset by ticker",
        "tags": ["RWA"],
        "parameters": [{ "name": "symbol", "in": "path", "required": true, "schema": { "type": "string" }, "example": "AAPL" }],
        "responses": { "200": { "$ref": "#/components/responses/Ok" }, "402": { "$ref": "#/components/responses/PaymentRequired" }, "403": { "$ref": "#/components/responses/AuthRequired" }, "429": { "$ref": "#/components/responses/RateLimited" } }
      }
    },
    "/api/cli/watch/{stream}": {
      "get": {
        "operationId": "watch",
        "summary": "Stream updates as NDJSON",
        "description": "Newline-delimited JSON, one object per line, sent every `interval` seconds until the client disconnects. Opening a stream counts against your quota. Streams cannot be paid per call, so a spent quota answers 429.",
        "tags": ["Streaming"],
        "parameters": [
          { "name": "stream", "in": "path", "required": true, "schema": { "type": "string", "enum": ["funding", "regime", "sentiment"] } },
          { "name": "interval", "in": "query", "schema": { "type": "integer", "default": 30, "minimum": 10, "maximum": 300 }, "description": "Seconds between emissions. Clamped." },
          { "name": "max", "in": "query", "schema": { "type": "integer" }, "description": "Stop after this many emissions. `0` streams indefinitely." },
          { "name": "diff", "in": "query", "schema": { "type": "boolean" }, "description": "Emit only when the payload changed." }
        ],
        "responses": {
          "200": { "description": "NDJSON stream.", "content": { "application/x-ndjson": { "schema": { "type": "string" } } } },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "403": { "$ref": "#/components/responses/AuthRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/cli/billing/tier": {
      "get": {
        "operationId": "getTier",
        "summary": "Your plan",
        "description": "The plan the API applies to this token. Free, and works when your quota is spent.",
        "tags": ["Account"],
        "responses": {
          "200": {
            "description": "Entitlement.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Envelope" },
                "example": {
                  "schemaVersion": 1,
                  "data": { "tier": "pro", "source": "manual", "expiresAt": null, "identity": { "kind": "apiKey", "userId": 42, "walletAddress": null } },
                  "meta": { "ts": "2026-08-11T15:22:43.000Z" }
                }
              }
            }
          },
          "403": { "$ref": "#/components/responses/AuthRequired" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key (`shumi_sk_…`) or a session JWT. Create a key with `shumi login` and `shumi keys create`."
      }
    },
    "parameters": {
      "SymbolPath": { "name": "symbol", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Uppercase ticker.", "example": "BTC" },
      "CategoryPath": { "name": "name", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Exact category name.", "example": "RWA (Real World Assets)" }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "description": "Success envelope. `schemaVersion` only changes on a breaking shape change, so a pinned client can detect one.",
        "required": ["schemaVersion", "data", "meta"],
        "properties": {
          "schemaVersion": { "type": "integer", "example": 1 },
          "data": { "description": "Route-specific payload." },
          "meta": {
            "type": "object",
            "properties": {
              "ts": { "type": "string", "format": "date-time", "description": "When this response was produced." },
              "as_of": { "type": "string", "format": "date-time", "description": "Timestamp of the underlying data, when it carries one." },
              "data_age_seconds": { "type": "integer", "description": "Age of the underlying data. Present alongside `as_of`." }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["schemaVersion", "error"],
        "properties": {
          "schemaVersion": { "type": "integer", "example": 1 },
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": { "type": "string", "enum": ["BAD_REQUEST", "AUTH_REQUIRED", "AUTH_INVALID", "RATE_LIMITED", "UPSTREAM_4XX", "UPSTREAM_5XX", "NETWORK", "INTERNAL"] },
              "message": { "type": "string" },
              "details": { "description": "Present when the route can say something more specific." }
            }
          }
        }
      }
    },
    "responses": {
      "Ok": { "description": "Success.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Envelope" } } } },
      "BadRequest": {
        "description": "A parameter is missing or invalid. The message names it.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "schemaVersion": 1, "error": { "code": "BAD_REQUEST", "message": "action=movements requires ?contract=<token address>" } } } }
      },
      "AuthRequired": {
        "description": "No token was sent.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "schemaVersion": 1, "error": { "code": "AUTH_REQUIRED", "message": "Authentication required. Send an API key as \"Authorization: Bearer shumi_sk_...\", or run: shumi login" } } } }
      },
      "Unauthorized": {
        "description": "The token was rejected: malformed, unknown, expired or revoked.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "schemaVersion": 1, "error": { "code": "AUTH_INVALID", "message": "API key has expired" } } } }
      },
      "PaymentRequired": {
        "description": "Your free questions are used up. The body is an x402 challenge: pay for this one call in USDC on Base and resend it with the `X-PAYMENT` header. A data call costs 0.005 USDC; a plain-word question, `pairs` or `walkforward` 0.05 USDC.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "x402Version": { "type": "integer" },
                "accepts": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "scheme": { "type": "string" },
                      "network": { "type": "string" },
                      "maxAmountRequired": { "type": "string", "description": "Price in USDC's smallest unit (6 decimals): `5000` is 0.005 USDC." },
                      "resource": { "type": "string" },
                      "payTo": { "type": "string" },
                      "asset": { "type": "string", "description": "USDC contract on Base." },
                      "maxTimeoutSeconds": { "type": "integer" },
                      "extra": { "type": "object" }
                    }
                  }
                }
              }
            },
            "example": {
              "x402Version": 1,
              "accepts": [{ "scheme": "exact", "network": "base", "maxAmountRequired": "5000", "resource": "https://api.shumi.ai/api/cli/coin/risk/DOGE", "payTo": "0x...", "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "maxTimeoutSeconds": 60, "extra": { "name": "USD Coin", "version": "2" } }]
            }
          }
        }
      },
      "RateLimited": {
        "description": "Quota used up on a call that cannot be paid per call: a paid plan's daily limit, a live stream, or a Free account when pay-per-call is unavailable.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "schemaVersion": 1, "error": { "code": "RATE_LIMITED", "message": "Quota exceeded (50/50 on access); resets at 00:00 UTC, or upgrade to Pro for unlimited" } } } }
      },
      "PlainError": {
        "description": "Error. This route returns a bare { error } object.",
        "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } }
      }
    }
  }
}
