{
  "openapi": "3.1.0",
  "info": {
    "title": "TerminalFeed API",
    "summary": "Real-time aggregated data for AI agents. Free tier plus USDC-paid premium tier with cross-site credits on TensorFeed.",
    "description": "TerminalFeed serves a free public API with no auth (markets, crypto, news, weather, space, infrastructure status) and a premium tier of composed multi-source endpoints gated by bearer-token auth. Premium credits are bought with USDC on Base mainnet and are jointly redeemable on tensorfeed.ai. Free endpoints have no SLA but return stale cache on upstream failure rather than 5xx. Premium endpoints are billed atomically: credits decrement before the upstream fetch begins, so partial-success responses still count. Schema stability: new fields may be added at any time; existing documented fields, URL paths, and _meta.sources[].name identifiers will not change without 90 days of deprecation notice via /changelog and X-TerminalFeed-Deprecation response header. See https://terminalfeed.io/terms#schema-stability.",
    "version": "1.15.0",
    "contact": {
      "name": "TerminalFeed Support",
      "url": "https://terminalfeed.io/developers/agent-payments",
      "email": "support@terminalfeed.io"
    },
    "license": {
      "name": "Free tier: permissive use. Premium tier: inference-only, see Terms section 17.",
      "url": "https://terminalfeed.io/terms#premium"
    },
    "termsOfService": "https://terminalfeed.io/terms"
  },
  "servers": [
    {
      "url": "https://terminalfeed.io",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "free",
      "description": "Free real-time data endpoints. No auth required. Standard rate limits."
    },
    {
      "name": "pro",
      "description": "Premium composed endpoints. Bearer auth required. Pay per call in USDC credits."
    },
    {
      "name": "payment",
      "description": "Credit purchase, confirmation, and balance check. No auth except where indicated."
    }
  ],
  "components": {
    "securitySchemes": {
      "agentBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "tf_live_<64-char-hex>",
        "description": "Bearer token from /api/payment/confirm. Same token works on tensorfeed.ai (shared credit pool). See https://terminalfeed.io/developers/agent-payments."
      }
    },
    "schemas": {
      "PremiumPaymentRequired": {
        "type": "object",
        "required": [
          "error",
          "signup",
          "pricing"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "missing_token",
              "invalid_token",
              "insufficient_credits",
              "expired",
              "billing_unavailable",
              "payment_required"
            ],
            "description": "Reason the request was rejected. Use this to disambiguate retry strategy."
          },
          "signup": {
            "type": "string",
            "format": "uri",
            "example": "https://terminalfeed.io/developers/agent-payments"
          },
          "pricing": {
            "type": "object",
            "properties": {
              "$1_usd": {
                "type": "string",
                "example": "50_credits"
              }
            }
          }
        }
      },
      "BriefingPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/briefing"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "sections": {
            "type": "object",
            "properties": {
              "btc": {
                "type": "object",
                "properties": {
                  "price_usd": {
                    "type": "number"
                  },
                  "change_24h_percent": {
                    "type": "number"
                  },
                  "volume_24h": {
                    "type": "number"
                  },
                  "high_24h": {
                    "type": "number"
                  },
                  "low_24h": {
                    "type": "number"
                  }
                }
              },
              "fear_greed": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "label": {
                    "type": "string",
                    "example": "Greed"
                  }
                }
              },
              "earthquakes": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "latest": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "magnitude": {
                        "type": "number"
                      },
                      "place": {
                        "type": "string"
                      },
                      "time": {
                        "type": "integer"
                      }
                    }
                  }
                }
              },
              "hackernews": {
                "type": "object",
                "properties": {
                  "top_story_count": {
                    "type": "integer"
                  }
                }
              },
              "humans_in_space": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "names": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "predictions": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "top": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "question": {
                          "type": "string"
                        },
                        "volume_24hr": {
                          "type": "number"
                        },
                        "outcomes": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "series": {
            "type": "object",
            "description": "Present only when ?history=24h is requested.",
            "properties": {
              "btc_24h": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "ts": {
                      "type": "integer",
                      "description": "ms since epoch"
                    },
                    "price": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "MacroPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/macro"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "economic": {
            "type": "object",
            "description": "FRED macro indicators. Each entry has value, date (ISO yyyy-mm-dd), source.",
            "properties": {
              "fed_rate": {
                "$ref": "#/components/schemas/FredEntry"
              },
              "cpi": {
                "$ref": "#/components/schemas/FredEntry"
              },
              "unemployment": {
                "$ref": "#/components/schemas/FredEntry"
              },
              "gdp_growth": {
                "$ref": "#/components/schemas/FredEntry"
              },
              "treasury_10y": {
                "$ref": "#/components/schemas/FredEntry"
              }
            }
          },
          "forex": {
            "type": "object",
            "properties": {
              "base": {
                "type": "string",
                "example": "USD"
              },
              "date": {
                "type": "string",
                "format": "date"
              },
              "rates": {
                "type": "object",
                "additionalProperties": {
                  "type": "number"
                },
                "example": {
                  "EUR": 0.92,
                  "JPY": 152.4,
                  "GBP": 0.78,
                  "CHF": 0.88
                }
              },
              "series": {
                "type": "object",
                "description": "Present only when ?history=30d is requested.",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "date": {
                        "type": "string",
                        "format": "date"
                      },
                      "value": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          },
          "commodities": {
            "type": "object",
            "properties": {
              "gold": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "price_usd": {
                    "type": "number"
                  },
                  "source": {
                    "type": "string",
                    "example": "paxg/kraken"
                  }
                }
              },
              "silver": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "Omitted in v1. Will be added when a stable free upstream surfaces."
              },
              "oil": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "price_usd": {
                    "type": "number"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "source": {
                    "type": "string"
                  }
                }
              },
              "nat_gas": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "price_usd": {
                    "type": "number"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "source": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "markets": {
            "type": "object",
            "properties": {
              "spy": {
                "$ref": "#/components/schemas/QuoteEntry"
              },
              "dia": {
                "$ref": "#/components/schemas/QuoteEntry"
              },
              "qqq": {
                "$ref": "#/components/schemas/QuoteEntry"
              },
              "vix": {
                "$ref": "#/components/schemas/QuoteEntry"
              }
            }
          },
          "notes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "CryptoDeepPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/crypto-deep"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "coins_top50": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "price_usd": {
                  "type": "number"
                },
                "change_1h_percent": {
                  "type": "number"
                },
                "change_24h_percent": {
                  "type": "number"
                },
                "change_7d_percent": {
                  "type": "number"
                },
                "market_cap": {
                  "type": "number"
                },
                "volume_24h": {
                  "type": "number"
                },
                "rank": {
                  "type": "integer"
                }
              }
            }
          },
          "binance_top20_usdt": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "pair": {
                  "type": "string",
                  "example": "BTCUSDT"
                },
                "price": {
                  "type": "number"
                },
                "change_24h_percent": {
                  "type": "number"
                },
                "volume_24h": {
                  "type": "number"
                },
                "high_24h": {
                  "type": "number"
                },
                "low_24h": {
                  "type": "number"
                },
                "trades_24h": {
                  "type": "integer"
                }
              }
            }
          },
          "network_btc": {
            "type": "object",
            "properties": {
              "block_height": {
                "type": "integer"
              },
              "fees_sat_per_vb": {
                "type": "object",
                "properties": {
                  "fastest": {
                    "type": "integer"
                  },
                  "half_hour": {
                    "type": "integer"
                  },
                  "hour": {
                    "type": "integer"
                  },
                  "economy": {
                    "type": "integer"
                  },
                  "minimum": {
                    "type": "integer"
                  }
                }
              },
              "hashrate": {
                "type": "object",
                "properties": {
                  "current_eh_s": {
                    "type": "number"
                  },
                  "current_difficulty": {
                    "type": "number"
                  }
                }
              },
              "mempool": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer"
                  },
                  "vsize": {
                    "type": "integer"
                  },
                  "total_fee_sat": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "eth_gas": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "low_gwei": {
                "type": "integer"
              },
              "standard_gwei": {
                "type": "integer"
              },
              "fast_gwei": {
                "type": "integer"
              },
              "base_fee_gwei": {
                "type": "number"
              },
              "last_block": {
                "type": "integer"
              }
            }
          },
          "series": {
            "type": "object",
            "description": "Present only when ?history=30d is requested.",
            "properties": {
              "btc_30d": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "ts": {
                      "type": "integer"
                    },
                    "low": {
                      "type": "number"
                    },
                    "high": {
                      "type": "number"
                    },
                    "open": {
                      "type": "number"
                    },
                    "close": {
                      "type": "number"
                    },
                    "volume": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "FredEntry": {
        "type": "object",
        "properties": {
          "value": {
            "type": [
              "number",
              "null"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "source": {
            "type": "string",
            "example": "fred:FEDFUNDS"
          },
          "series": {
            "type": "array",
            "description": "Present only when ?history=30d is requested.",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "value": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "QuoteEntry": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "price": {
            "type": "number"
          },
          "change": {
            "type": "number"
          },
          "change_percent": {
            "type": "number"
          }
        }
      },
      "BuyCreditsRequest": {
        "type": "object",
        "required": [
          "amount_usd"
        ],
        "properties": {
          "amount_usd": {
            "type": "number",
            "minimum": 1,
            "description": "USDC amount to convert. $1 = 50 credits."
          }
        }
      },
      "BuyCreditsResponse": {
        "type": "object",
        "properties": {
          "wallet": {
            "type": "string",
            "example": "0x549c82e6bfc54bdae9a2073744cbc2af5d1fc6d1"
          },
          "memo": {
            "type": "string",
            "example": "tf_buy_a1b2c3"
          },
          "quote": {
            "type": "object",
            "properties": {
              "amount_usd": {
                "type": "number"
              },
              "credits": {
                "type": "integer"
              },
              "chain": {
                "type": "string",
                "example": "base"
              }
            }
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ConfirmPaymentRequest": {
        "type": "object",
        "required": [
          "tx_hash",
          "nonce"
        ],
        "properties": {
          "tx_hash": {
            "type": "string",
            "description": "On-chain Base mainnet USDC transfer hash."
          },
          "nonce": {
            "type": "string",
            "description": "The memo string returned from /api/payment/buy-credits."
          }
        }
      },
      "ConfirmPaymentResponse": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "example": "tf_live_<64-char-hex>"
          },
          "credits": {
            "type": "integer",
            "example": 50
          }
        }
      },
      "BalanceResponse": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "integer"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SentimentPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/sentiment"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "market_indices": {
            "type": "object",
            "properties": {
              "crypto_fear_greed": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "value": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "label": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string",
                    "example": "alternative.me"
                  }
                }
              },
              "stocks_vix": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "value": {
                    "type": "number"
                  },
                  "change_percent": {
                    "type": "number"
                  },
                  "label": {
                    "type": "string",
                    "enum": [
                      "low_volatility",
                      "normal",
                      "elevated",
                      "high_volatility",
                      "unknown"
                    ]
                  },
                  "source": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "trending": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string"
                },
                "asset_class": {
                  "type": "string",
                  "enum": [
                    "crypto",
                    "equity",
                    "crypto-equity"
                  ]
                },
                "mention_count_24h": {
                  "type": "integer"
                },
                "sources": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "integer"
                  }
                },
                "sentiment_score": {
                  "type": "number",
                  "minimum": -1,
                  "maximum": 1
                },
                "sentiment_label": {
                  "type": "string",
                  "enum": [
                    "negative",
                    "moderately_negative",
                    "neutral",
                    "moderately_positive",
                    "positive"
                  ]
                },
                "sample_headlines": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "title": {
                        "type": "string"
                      },
                      "url": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "source": {
                        "type": "string"
                      },
                      "sentiment_signal": {
                        "type": "string",
                        "enum": [
                          "+",
                          "-",
                          "neutral"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "prediction_markets_signals": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "question": {
                  "type": "string"
                },
                "yes_probability": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "volume_24h": {
                  "type": "number"
                },
                "url": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "sample_size": {
            "type": "object",
            "properties": {
              "headlines_scanned": {
                "type": "integer"
              },
              "tickers_with_mentions": {
                "type": "integer"
              }
            }
          },
          "notes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "WorldDeltasPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/world-deltas"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "since": {
            "type": "string",
            "format": "date-time"
          },
          "since_clamped": {
            "type": "boolean"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "earthquake",
                    "hn_story",
                    "polymarket_update",
                    "space_launch"
                  ]
                },
                "timestamp": {
                  "type": "string",
                  "format": "date-time"
                },
                "severity": {
                  "type": "string",
                  "enum": [
                    "minor",
                    "moderate",
                    "major"
                  ]
                },
                "data": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "sample_size": {
            "type": "object"
          },
          "notes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "AgentContextPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "example": "terminalfeed-pro"
          },
          "endpoint": {
            "type": "string",
            "example": "/api/pro/agent-context"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "context": {
            "type": "object",
            "properties": {
              "datetime": {
                "type": "object"
              },
              "markets": {
                "type": "object",
                "properties": {
                  "btc": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "crypto_fear_greed": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "vix": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "fed_funds_rate": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "forex_usd_base": {
                    "type": "object"
                  }
                }
              },
              "world_events": {
                "type": "object",
                "properties": {
                  "significant_earthquakes_24h": {
                    "type": "array"
                  },
                  "upcoming_space_launches": {
                    "type": "array"
                  },
                  "hn_front_page_top5": {
                    "type": "array"
                  },
                  "prediction_markets_top3": {
                    "type": "array"
                  }
                }
              },
              "infrastructure": {
                "type": "object",
                "properties": {
                  "summary": {
                    "type": "string"
                  },
                  "details": {
                    "type": "object"
                  },
                  "all_operational": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "system_prompt": {
            "type": "string",
            "description": "Pre-formatted multi-line string an agent pastes verbatim into LLM context. Target ~350 tokens."
          },
          "notes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "CorrelationMatrixPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "window": {
            "type": "string",
            "example": "30d"
          },
          "method": {
            "type": "string"
          },
          "assets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string"
                },
                "asset_class": {
                  "type": "string"
                },
                "observations": {
                  "type": "integer"
                }
              }
            }
          },
          "pairs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "a": {
                  "type": "string"
                },
                "b": {
                  "type": "string"
                },
                "pearson_r": {
                  "type": "number",
                  "minimum": -1,
                  "maximum": 1
                },
                "n_observations": {
                  "type": "integer"
                },
                "relationship": {
                  "type": "string",
                  "enum": [
                    "negligible",
                    "weak",
                    "moderate",
                    "strong"
                  ]
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "positive",
                    "negative",
                    "none"
                  ]
                }
              }
            }
          },
          "matrix": {
            "type": "object"
          },
          "sample_size": {
            "type": "object"
          },
          "notes": {
            "type": "object"
          }
        }
      },
      "WhalesPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "spot_prices": {
            "type": "object"
          },
          "btc_whales_unconfirmed": {
            "type": "array"
          },
          "eth_whales_latest_block": {
            "type": "array"
          },
          "eth_block": {
            "type": "object"
          },
          "eth_blocks_scanned": {
            "type": "array"
          },
          "aggregate": {
            "type": "object"
          },
          "thresholds": {
            "type": "object"
          },
          "notes": {
            "type": "object"
          }
        }
      },
      "ExchangeFlowsPro": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "spot_eth_usd": {
            "type": [
              "number",
              "null"
            ]
          },
          "blocks_scanned": {
            "type": "array"
          },
          "flows_by_exchange": {
            "type": "array"
          },
          "recent_transfers": {
            "type": "array"
          },
          "aggregate": {
            "type": "object",
            "properties": {
              "transfer_count": {
                "type": "integer"
              },
              "total_inflow_eth": {
                "type": "number"
              },
              "total_outflow_eth": {
                "type": "number"
              },
              "net_flow_eth": {
                "type": "number"
              },
              "net_flow_usd": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "bias": {
                "type": "string",
                "enum": [
                  "inflow_dominant",
                  "outflow_dominant",
                  "balanced"
                ]
              }
            }
          },
          "threshold": {
            "type": "object"
          },
          "exchanges_tracked": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "object"
          }
        }
      }
    },
    "responses": {
      "PremiumPaymentRequired": {
        "description": "Premium endpoint refused: missing or invalid bearer, insufficient credits, or billing service unreachable.",
        "headers": {
          "X-TerminalFeed-Pricing": {
            "schema": {
              "type": "string"
            },
            "description": "URL pointing at /developers/agent-payments."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PremiumPaymentRequired"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/health": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Worker health check",
        "responses": {
          "200": {
            "description": "OK with version + uptime.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "uptime": {
                      "type": "integer"
                    },
                    "ts": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/briefing": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Free one-call world snapshot",
        "description": "Compact summary of BTC, Fear & Greed, recent earthquakes, top HN story count, and ISS crew. For richer composition with predictions and history, see GET /api/pro/briefing.",
        "responses": {
          "200": {
            "description": "Aggregated snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/btc-price": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Bitcoin price (Binance with CoinCap fallback)",
        "responses": {
          "200": {
            "description": "Live BTC ticker.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/crypto-movers": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Top 15 crypto movers by 24h change",
        "responses": {
          "200": {
            "description": "Movers list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/fear-greed": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Crypto Fear & Greed Index (Alternative.me)",
        "responses": {
          "200": {
            "description": "Index value 0-100 with label.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/stocks": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Top US stocks (Finnhub)",
        "parameters": [
          {
            "name": "symbols",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Optional comma list of tickers, e.g. AAPL,MSFT,NVDA"
          }
        ],
        "responses": {
          "200": {
            "description": "Quotes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/forex": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Currency rates (Frankfurter, USD base)",
        "responses": {
          "200": {
            "description": "Latest + previous-day rates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/economic-data": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "FRED indicators (Fed rate, CPI, unemployment, GDP)",
        "responses": {
          "200": {
            "description": "Latest macro readings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/predictions": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Polymarket prediction markets",
        "responses": {
          "200": {
            "description": "Active markets sorted by 24h volume.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/earthquake": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Recent earthquakes M2.5+ (USGS)",
        "responses": {
          "200": {
            "description": "Quake list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/disaster-alerts": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Global disaster alerts (GDACS)",
        "responses": {
          "200": {
            "description": "Active disaster alerts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/launches": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Upcoming space launches (The Space Devs)",
        "responses": {
          "200": {
            "description": "Launch manifest.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/humans-in-space": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "ISS crew (Open Notify)",
        "responses": {
          "200": {
            "description": "Crew count and names.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/cyber-threats": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Malware and IOCs (URLhaus + ThreatFox)",
        "responses": {
          "200": {
            "description": "Recent threats.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/service-status": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Status of GitHub, Cloudflare, OpenAI, Anthropic, etc.",
        "responses": {
          "200": {
            "description": "Per-service status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/gas": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Ethereum gas oracle (Etherscan)",
        "responses": {
          "200": {
            "description": "Gwei prices low/standard/fast.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/hf-trending": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "HuggingFace trending models (top 15 by 7-day likes)",
        "responses": {
          "200": {
            "description": "Array of trending models with id, author, name, likes, downloads, pipeline, url, updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/space-weather": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "NOAA SWPC: Kp index, solar wind, X-ray flare class, active alerts",
        "description": "Geomagnetic Kp index, solar wind speed/density, peak X-ray flare class over last 24h (A/B/C/M/X), and up to 5 active NOAA space weather alerts. Source: services.swpc.noaa.gov. 5-minute cache.",
        "responses": {
          "200": {
            "description": "Current space weather snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/wildfires": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "NASA FIRMS active fire detections (North America 24h)",
        "description": "Top 25 most intense satellite fire detections in North America over last 24 hours, sorted by Fire Radiative Power (MW). Includes lat/lon, approximate US state, satellite, confidence. Source: NASA FIRMS VIIRS SNPP NRT. 10-minute cache. Requires NASA_FIRMS_MAP_KEY env var on the worker.",
        "responses": {
          "200": {
            "description": "Wildfire detections snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/severe-weather": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "NWS active US severe weather alerts (top 15 by severity)",
        "description": "Top 15 active National Weather Service alerts ranked by severity score (severity x urgency x certainty). Tornado, flood, severe thunderstorm, hurricane, winter storm, fire, heat, wind. Source: api.weather.gov. 60-second cache.",
        "responses": {
          "200": {
            "description": "Active severe weather alerts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/climate/earthquakes": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "USGS pre-built earthquake summary feed (parameterized)",
        "description": "USGS Earthquake Hazards Program summary feeds. Selectable magnitude bucket (significant, 4.5, 2.5, 1.0, all) crossed with period (hour, day, week, month). 20 selectable feeds. Returns a flattened list (id, magnitude, place, time ISO 8601, depth_km, lat, lon, tsunami, USGS detail URL). Cache TTL scales with feed window (60s for hour up to 900s for month). US Government public domain (17 USC §105). Mirrors TensorFeed's same-named endpoint for federation parity.",
        "parameters": [
          {
            "name": "magnitude",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "significant",
                "4.5",
                "2.5",
                "1.0",
                "all"
              ]
            },
            "description": "Magnitude bucket. Default 2.5."
          },
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ]
            },
            "description": "Period bucket. Default day."
          }
        ],
        "responses": {
          "200": {
            "description": "Earthquake feed for the selected bucket",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/climate/weather-alerts": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "NWS active alerts (parameterized, US-only)",
        "description": "Active National Weather Service alerts from api.weather.gov, filterable by 2-letter US state code, exact NWS event name, severity, urgency, and status. Returns id, event, severity, urgency, certainty, headline, description, areaDesc, sent/effective/expires/ends, sender_name, web URL. 60-second cache. NWS-required User-Agent header sent on every fetch. US Government public domain (17 USC §105). Mirrors TensorFeed's same-named endpoint for federation parity.",
        "parameters": [
          {
            "name": "area",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "2-letter US state code, e.g. CA, NY."
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact NWS event name, e.g. \"Tornado Warning\", \"Heat Advisory\"."
          },
          {
            "name": "severity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Extreme",
                "Severe",
                "Moderate",
                "Minor",
                "Unknown"
              ]
            },
            "description": "Alert severity."
          },
          {
            "name": "urgency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Immediate",
                "Expected",
                "Future",
                "Past",
                "Unknown"
              ]
            },
            "description": "Alert urgency."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "Actual",
                "Exercise",
                "System",
                "Test",
                "Draft"
              ]
            },
            "description": "Alert status."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Max alerts (1-100). Default 50."
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered active alerts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/funding-rates": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Top 20 perp futures funding rates across 4 venues",
        "description": "Top 20 perpetual futures contracts by absolute annualized funding rate, across Binance USD-M, Bybit linear, dYdX v4, and Hyperliquid. Includes venue, symbol, period rate, annualized %, mark price. 60-second cache.",
        "responses": {
          "200": {
            "description": "Funding rate leaderboard",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/air-quality": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Open-Meteo Air Quality (US AQI, PM2.5, PM10, ozone, NO2)",
        "description": "Air quality snapshot for any lat/lon. Returns US AQI band, European AQI, PM2.5, PM10, ozone, nitrogen dioxide, sulphur dioxide, carbon monoxide. Per-coordinates cache (rounded to 2 decimals) for 30 minutes. Defaults to Los Angeles when lat/lon are missing or invalid. Source: Open-Meteo Air Quality API.",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "Latitude (-90 to 90). Default 34.05."
          },
          {
            "name": "lon",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "Longitude (-180 to 180). Default -118.24."
          }
        ],
        "responses": {
          "200": {
            "description": "Air quality snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/shodan": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Shodan InternetDB exposure scan (no key required)",
        "description": "Shodan InternetDB lookup. Returns open ports, known CVEs, hostnames, tags, and CPEs for public IPv4 addresses. With no parameters, returns a curated rotation across Cloudflare DNS, Google DNS, Quad9, OpenDNS, GitHub, and Fastly. With ?ip=, looks up any single public IPv4. Private and reserved ranges are rejected. 1-hour cache.",
        "parameters": [
          {
            "name": "ip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Public IPv4 address. Omit for the curated demo set."
          }
        ],
        "responses": {
          "200": {
            "description": "Exposure snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/volcanoes": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Smithsonian GVP weekly volcano activity report",
        "description": "Latest volcano activity reports from the Smithsonian Institution Global Volcanism Program weekly bulletin. Includes volcano name, country, summary, and link. 1-hour cache.",
        "responses": {
          "200": {
            "description": "Active volcano reports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/harnesses": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Agentic-coding harness leaderboards (Claude Code, Cursor, Codex, Aider, OpenHands, Devin, SWE-Agent)",
        "description": "Snapshot of public benchmark scores across SWE-bench Verified, Terminal-Bench, Aider Polyglot, and METR HCAST. Each row pairs a harness with a model, and same-model cross-harness gaps are exposed as a first-class metric. Hand-curated weekly. 12-hour cache. CORS enabled, no auth required.",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "raw",
                "summary",
                "gaps",
                "combined"
              ],
              "default": "raw"
            },
            "description": "raw=full benchmark/result graph, summary=top combined leaderboard plus biggest harness gaps, gaps=full per-model harness deltas, combined=normalized cross-benchmark ranking"
          }
        ],
        "responses": {
          "200": {
            "description": "Harness leaderboard snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/solana-network": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Solana network health (live TPS, slot, slot time, epoch)",
        "responses": {
          "200": {
            "description": "Live Solana network metrics: tps (most recent 60s sample), tpsAvg (3-sample average), slot, slotMs, epoch, epochProgress.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/weather": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Weather (Open-Meteo)",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current weather and hourly forecast.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/pro/briefing": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium briefing: 6 upstream sources composed (1 credit)",
        "description": "All free /api/briefing modules plus Polymarket prediction markets, optional include filter, and optional 24-hour BTC chart series. Returns 402 Payment Required when auth fails or credits are exhausted; the credit is decremented before the upstream fetch begins, so partial-fetch responses still count.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated subset: btc,fear-greed,earthquakes,hackernews,humans-in-space,predictions"
          },
          {
            "name": "history",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "24h"
              ]
            },
            "description": "When set to 24h, response includes a series.btc_24h hourly array."
          }
        ],
        "responses": {
          "200": {
            "description": "Composed briefing.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BriefingPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/briefing \\\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nres = requests.get(\n    \"https://terminalfeed.io/api/pro/briefing\",\n    headers={\"Authorization\": \"Bearer tf_live_<64-char-hex>\"},\n    timeout=10,\n)\nprint(res.json())\nprint(\"credits left:\", res.headers.get(\"X-Credits-Remaining\"))"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const res = await fetch(\"https://terminalfeed.io/api/pro/briefing\", {\n  headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" },\n});\nconst data = await res.json();\nconsole.log(data);\nconsole.log(\"credits left:\", res.headers.get(\"X-Credits-Remaining\"));"
          }
        ],
        "x-pricing-credits": 1,
        "x-pricing-usd": 0.02,
        "x-composes-sources": 6,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          }
        }
      }
    },
    "/api/pro/macro": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium macro snapshot: FRED + forex + commodities + indices (2 credits)",
        "description": "Composes ~14 upstream calls into one response: 7 FRED economic series, 4 USD-base forex rates, gold via PAXG, US indices SPY/DIA/QQQ, and VIX. Optional 30-day history.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "parameters": [
          {
            "name": "history",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "30d"
              ]
            },
            "description": "When set, FRED entries include a series array and forex.series is populated."
          }
        ],
        "responses": {
          "200": {
            "description": "Composed macro snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MacroPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl \"https://terminalfeed.io/api/pro/macro?history=30d\" \\\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nres = requests.get(\n    \"https://terminalfeed.io/api/pro/macro\",\n    params={\"history\": \"30d\"},\n    headers={\"Authorization\": \"Bearer tf_live_<64-char-hex>\"},\n    timeout=15,\n)\nmacro = res.json()\nprint(\"Fed rate:\", macro[\"economic\"][\"fed_rate\"][\"value\"])\nprint(\"VIX:\", macro[\"markets\"][\"vix\"][\"price\"])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const url = new URL(\"https://terminalfeed.io/api/pro/macro\");\nurl.searchParams.set(\"history\", \"30d\");\nconst res = await fetch(url, {\n  headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" },\n});\nconst macro = await res.json();\nconsole.log(\"Fed rate:\", macro.economic.fed_rate.value);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 14,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/crypto-deep": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium crypto deep snapshot: top 50 + Binance + on-chain + gas (2 credits)",
        "description": "Composes 7 upstream sources: top 50 coins by market cap with 1h/24h/7d change, Binance top 20 USDT pairs by volume with high/low/trade-count, Bitcoin network stats from mempool.space (block height, fee tiers, hashrate, mempool size), and Etherscan gas oracle. Optional 30-day BTC OHLCV.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "parameters": [
          {
            "name": "coins",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated symbol filter, e.g. btc,eth,sol"
          },
          {
            "name": "history",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "30d"
              ]
            },
            "description": "When set, response includes series.btc_30d."
          }
        ],
        "responses": {
          "200": {
            "description": "Composed crypto-deep snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoDeepPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl \"https://terminalfeed.io/api/pro/crypto-deep?coins=btc,eth,sol\" \\\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nres = requests.get(\n    \"https://terminalfeed.io/api/pro/crypto-deep\",\n    params={\"coins\": \"btc,eth,sol\"},\n    headers={\"Authorization\": \"Bearer tf_live_<64-char-hex>\"},\n    timeout=15,\n)\nd = res.json()\nfor coin in d[\"coins_top50\"]:\n    print(coin[\"symbol\"], coin[\"price_usd\"], coin[\"change_24h_percent\"])\nprint(\"BTC block height:\", d[\"network_btc\"][\"block_height\"])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const url = new URL(\"https://terminalfeed.io/api/pro/crypto-deep\");\nurl.searchParams.set(\"coins\", \"btc,eth,sol\");\nconst res = await fetch(url, { headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" } });\nconst d = await res.json();\nfor (const c of d.coins_top50) console.log(c.symbol, c.price_usd);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 7,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/payment/info": {
      "get": {
        "tags": [
          "payment"
        ],
        "summary": "Self-describing payment metadata",
        "description": "Returns the published USDC wallet address, pricing tiers, supported payment flows (credits-first and x402 fallback), and verification metadata. No auth required. Useful as the first call in an agent's onboarding sequence.",
        "responses": {
          "200": {
            "description": "Payment metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-pricing-credits": 0,
        "x-pricing-usd": 0,
        "security": []
      }
    },
    "/api/payment/buy-credits": {
      "post": {
        "tags": [
          "payment"
        ],
        "summary": "Quote a credit purchase, return wallet + memo",
        "description": "Returns the published USDC wallet, a unique memo, and a quote tying the USD amount to credits. Send USDC on Base mainnet to the wallet, then call POST /api/payment/confirm with the tx hash and memo. Proxies to the TensorFeed payment Worker; the wallet returned must match the address published at /terms section 17, /developers/agent-payments, /llms.txt, and the GitHub README.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BuyCreditsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote with wallet and memo.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BuyCreditsResponse"
                }
              }
            }
          },
          "503": {
            "description": "Billing infrastructure not configured."
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST https://terminalfeed.io/api/payment/buy-credits \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"amount_usd\": 1.00}'"
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nquote = requests.post(\n    \"https://terminalfeed.io/api/payment/buy-credits\",\n    json={\"amount_usd\": 1.00},\n    timeout=10,\n).json()\nprint(\"Send\", quote[\"amount_usd\"], \"USDC to\", quote[\"wallet\"])\nprint(\"Memo:\", quote[\"memo\"])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const res = await fetch(\"https://terminalfeed.io/api/payment/buy-credits\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ amount_usd: 1.00 }),\n});\nconst quote = await res.json();\nconsole.log(\"Send\", quote.amount_usd, \"USDC to\", quote.wallet);"
          }
        ],
        "x-pricing-credits": 0,
        "x-pricing-usd": 0,
        "security": []
      }
    },
    "/api/payment/confirm": {
      "post": {
        "tags": [
          "payment"
        ],
        "summary": "Confirm USDC transfer, mint bearer token",
        "description": "Verifies the on-chain transaction and the memo, then returns a bearer token plus credit count. Replay-protected: the same tx hash will not credit twice.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmPaymentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bearer token issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfirmPaymentResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment not found, expired, or replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PremiumPaymentRequired"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl -X POST https://terminalfeed.io/api/payment/confirm \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"tx_hash\": \"0xabc...\", \"nonce\": \"tf-...\"}'"
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nresp = requests.post(\n    \"https://terminalfeed.io/api/payment/confirm\",\n    json={\"tx_hash\": \"0xabc...\", \"nonce\": \"tf-...\"},\n    timeout=15,\n).json()\ntoken = resp[\"token\"]\nprint(\"Bearer token:\", token, \"Credits:\", resp[\"credits\"])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const res = await fetch(\"https://terminalfeed.io/api/payment/confirm\", {\n  method: \"POST\",\n  headers: { \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ tx_hash: \"0xabc...\", nonce: \"tf-...\" }),\n});\nconst { token, credits } = await res.json();"
          }
        ],
        "x-pricing-credits": 0,
        "x-pricing-usd": 0,
        "security": []
      }
    },
    "/api/payment/balance": {
      "get": {
        "tags": [
          "payment"
        ],
        "summary": "Check remaining credits for a bearer token",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceResponse"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/payment/balance \\\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nbalance = requests.get(\n    \"https://terminalfeed.io/api/payment/balance\",\n    headers={\"Authorization\": \"Bearer tf_live_<64-char-hex>\"},\n    timeout=10,\n).json()\nprint(\"Credits remaining:\", balance[\"credits\"])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const res = await fetch(\"https://terminalfeed.io/api/payment/balance\", {\n  headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" },\n});\nconst balance = await res.json();\nconsole.log(\"Credits remaining:\", balance.credits);"
          }
        ],
        "x-pricing-credits": 0,
        "x-pricing-usd": 0
      }
    },
    "/api/llm-tools": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "Pre-baked function-calling tool definitions for OpenAI and Anthropic",
        "description": "Returns ready-to-paste tool definitions for every TerminalFeed endpoint in OpenAI function-calling format and Anthropic tool-use format. Free endpoint by design (no credits). Agent devs paste the openai or anthropic block directly into their LLM tool-use scaffold.",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "both",
                "openai",
                "anthropic",
                "raw"
              ]
            },
            "description": "Output format. Default both."
          },
          {
            "name": "tier",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "free",
                "premium"
              ]
            },
            "description": "Filter by tier. Default all."
          }
        ],
        "responses": {
          "200": {
            "description": "Tool definitions in requested format(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl \"https://terminalfeed.io/api/llm-tools?format=anthropic\""
          },
          {
            "lang": "Python",
            "label": "Python (Anthropic SDK)",
            "source": "import requests, anthropic\ntools = requests.get(\"https://terminalfeed.io/api/llm-tools?format=anthropic\").json()[\"anthropic\"]\nclient = anthropic.Anthropic()\nresp = client.messages.create(\n    model=\"claude-opus-4-7\",\n    tools=tools,\n    messages=[{\"role\": \"user\", \"content\": \"What is the current Fed funds rate?\"}],\n    max_tokens=1024,\n)"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (OpenAI SDK)",
            "source": "import OpenAI from \"openai\";\nconst tools = (await fetch(\"https://terminalfeed.io/api/llm-tools?format=openai\").then(r => r.json())).openai;\nconst openai = new OpenAI();\nconst resp = await openai.chat.completions.create({\n  model: \"gpt-4o\",\n  tools,\n  messages: [{ role: \"user\", content: \"Get the latest BTC price.\" }],\n});"
          }
        ],
        "security": []
      }
    },
    "/api/pro/sentiment": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium composite market sentiment (2 credits)",
        "description": "Composite market sentiment for AI trading and research agents. Aggregates Crypto Fear and Greed Index, VIX volatility (when Finnhub key has access), trending ticker mentions across Hacker News top 30 + Reddit hot posts (r/CryptoCurrency, r/wallstreetbets, r/stocks) with per-headline keyword-based sentiment scoring, and Polymarket-implied probabilities for top markets. Output includes per-ticker mention_count_24h, sentiment_score (-1 to +1), sentiment_label, and sample headlines with URLs. Notes field documents the scoring methodology (keyword-based, crude but signal-bearing) so agents can calibrate trust appropriately. 2 credits ($0.04). Bearer auth required. Cached at 5min.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Composite sentiment snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentimentPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/sentiment \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (requests)",
            "source": "import requests\nres = requests.get(\n    \"https://terminalfeed.io/api/pro/sentiment\",\n    headers={\"Authorization\": \"Bearer tf_live_<64-char-hex>\"},\n    timeout=15,\n)\ndata = res.json()\nprint(\"Crypto F&G:\", data[\"market_indices\"][\"crypto_fear_greed\"])\nfor t in data[\"trending\"][:5]:\n    print(t[\"symbol\"], t[\"sentiment_label\"], t[\"mention_count_24h\"], \"mentions\")"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (fetch)",
            "source": "const res = await fetch(\"https://terminalfeed.io/api/pro/sentiment\", {\n  headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" },\n});\nconst data = await res.json();\nfor (const t of data.trending.slice(0, 5)) {\n  console.log(t.symbol, t.sentiment_label, t.mention_count_24h);\n}"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 7,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/world-deltas": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium time-sorted event stream (2 credits)",
        "description": "Aggregates time-stamped events from 4 upstream sources into one time-sorted feed: USGS earthquakes M4.0+, Hacker News current front-page items (within the since window), recently updated Polymarket markets >= $10K 24h volume, and space launches in [-1h, +12h] window. Accepts ?since=<ISO timestamp>, defaults to 1 hour ago and clamped to the 1-hour cache horizon. Each event has type, timestamp, severity, and structured data. Saves a monitor agent from polling 4 separate upstream feeds and time-merging client-side. 2 credits ($0.04). Bearer auth. 1-hour rolling cache; sub-second response when warm.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "ISO 8601 timestamp. Returns events newer than this. Defaults to 1 hour ago. Clamped to 1 hour ago if older."
          }
        ],
        "responses": {
          "200": {
            "description": "Time-sorted event stream.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldDeltasPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl \"https://terminalfeed.io/api/pro/world-deltas?since=2026-04-27T22:00:00Z\" \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (monitor loop)",
            "source": "import requests, time\nfrom datetime import datetime, timezone, timedelta\n\nTOKEN = \"tf_live_<64-char-hex>\"\nlast_poll = datetime.now(timezone.utc) - timedelta(minutes=5)\n\nwhile True:\n    res = requests.get(\n        \"https://terminalfeed.io/api/pro/world-deltas\",\n        params={\"since\": last_poll.isoformat()},\n        headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n        timeout=15,\n    )\n    data = res.json()\n    for ev in data[\"events\"]:\n        print(ev[\"type\"], ev[\"severity\"], ev[\"data\"])\n    last_poll = datetime.now(timezone.utc)\n    time.sleep(300)  # 5 min cadence"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (polling)",
            "source": "const url = new URL(\"https://terminalfeed.io/api/pro/world-deltas\");\nurl.searchParams.set(\"since\", new Date(Date.now() - 5*60_000).toISOString());\nconst res = await fetch(url, { headers: { Authorization: \"Bearer tf_live_<64-char-hex>\" } });\nconst data = await res.json();\nfor (const ev of data.events) console.log(ev.type, ev.severity, ev.data);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 4,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/agent-context": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Curated 'always start here' world-state with paste-ready system_prompt (2 credits)",
        "description": "The 'always start here' premium call for autonomous agents. Composes 13 upstream sources into a curated world-state snapshot: BTC ticker, Fear & Greed, VIX, Fed funds rate, USD-base forex (EUR/JPY/GBP/CHF), HN front page top 5, significant earthquakes 24h, upcoming space launches, top 3 Polymarket markets by 24h volume, and infrastructure status (GitHub, Cloudflare, OpenAI, Anthropic). Returns BOTH a structured JSON `context` object for parsers AND a pre-formatted `system_prompt` string (~350 tokens) the agent pastes verbatim into its LLM context window. Saves the agent from making 13 separate calls and writing a formatter. The curation choice (which signals matter, how to compress them) is the moat. Costs 2 credits ($0.04). 5-min cache. Bearer auth required.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Curated world-state with structured context and paste-ready system_prompt.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "no-store"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentContextPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/agent-context \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python (paste system_prompt into Claude)",
            "source": "import requests, anthropic\nTOKEN = \"tf_live_<64-char-hex>\"\nctx = requests.get(\n    \"https://terminalfeed.io/api/pro/agent-context\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n    timeout=15,\n).json()\n\nclient = anthropic.Anthropic()\nresp = client.messages.create(\n    model=\"claude-opus-4-7\",\n    system=ctx[\"system_prompt\"],   # paste-ready, ~350 tokens of curated world state\n    messages=[{\"role\": \"user\", \"content\": \"Given the current macro context, what should I research?\"}],\n    max_tokens=1024,\n)\nprint(resp.content[0].text)"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript (paste into OpenAI)",
            "source": "import OpenAI from \"openai\";\nconst TOKEN = \"tf_live_<64-char-hex>\";\nconst ctx = await fetch(\"https://terminalfeed.io/api/pro/agent-context\", {\n  headers: { Authorization: `Bearer ${TOKEN}` },\n}).then(r => r.json());\n\nconst openai = new OpenAI();\nconst resp = await openai.chat.completions.create({\n  model: \"gpt-4o\",\n  messages: [\n    { role: \"system\", content: ctx.system_prompt },\n    { role: \"user\", content: \"What are the most notable signals in the current world state?\" },\n  ],\n});"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 13,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/correlation-matrix": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium 30-day cross-asset correlation matrix (2 credits)",
        "description": "Pre-computed Pearson correlation matrix on 30-day daily simple returns across up to 10 assets: BTC, ETH, SOL, AVAX, LINK (Coinbase candles, free), gold via PAXG-USD (Coinbase, free), and 10Y / 2Y treasury yields, trade-weighted USD index, WTI oil (FRED, requires FRED_API_KEY on the Worker). Returns both a pairs array (sorted by absolute r descending) and an NxN matrix object. Each pair tagged with relationship strength and direction. Saves the agent from fetching 10 historical price series and running covariance math. Costs 2 credits ($0.04 USDC). 30-min cache. Bearer auth required.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Correlation matrix.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CorrelationMatrixPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/correlation-matrix \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nm = requests.get(\n    \"https://terminalfeed.io/api/pro/correlation-matrix\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n    timeout=15,\n).json()\nfor p in m[\"pairs\"][:5]:\n    print(f\"{p['a']} <-> {p['b']}: {p['pearson_r']:+.3f}\")\nbtc_eth = m[\"matrix\"][\"BTC\"][\"ETH\"]"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const m = await fetch(\"https://terminalfeed.io/api/pro/correlation-matrix\", {\n  headers: { Authorization: `Bearer ${TOKEN}` },\n}).then(r => r.json());\nconst btcEth = m.matrix.BTC.ETH;\nconsole.log(\"BTC-ETH:\", btcEth);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 10,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/whales": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium large on-chain transaction tracker (2 credits)",
        "description": "Tracks whale-sized BTC and ETH transactions in near real time. BTC: scans mempool.space recent mempool (last 10 unconfirmed) for outputs >=10 BTC. ETH: scans the last 3 confirmed blocks (~36s of history, ~1900 transactions) via publicnode.com JSON-RPC for transfers >=100 ETH. Each whale entry tagged with USD-equivalent at current BTC/ETH spot, tx hash, addresses (ETH only), and explorer URL. Useful for trading bots watching for institutional flow signals: large exchange in/outflows, treasury moves, OTC settlements. Costs 2 credits ($0.04 USDC). 5-min cache. Bearer auth required.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Whale activity snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhalesPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/whales \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nw = requests.get(\n    \"https://terminalfeed.io/api/pro/whales\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n    timeout=15,\n).json()\nfor eth in w[\"eth_whales_latest_block\"]:\n    print(f\"{eth['value_eth']} ETH ~ ${eth['value_usd']:,}\")"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const w = await fetch(\"https://terminalfeed.io/api/pro/whales\", {\n  headers: { Authorization: `Bearer ${TOKEN}` },\n}).then(r => r.json());\nfor (const tx of w.eth_whales_latest_block) {\n  console.log(`${tx.value_eth} ETH = $${tx.value_usd}`);\n}"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 4,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/exchange-flows": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Premium ETH exchange flow tracker (2 credits)",
        "description": "Tracks ETH transfers in/out of major centralized exchange hot wallets (Binance, Coinbase, OKX, Kraken, Bybit, Crypto.com, KuCoin) across the last 3 confirmed blocks. Each transfer tagged as inflow (user -> exchange), outflow (exchange -> user), or inter_exchange. Per-exchange and aggregate net flows surfaced with USD-equivalents and a bias label. 5 ETH minimum threshold. Useful for trading bots watching for regime shifts. Costs 2 credits ($0.04 USDC). 5-min cache. Bearer auth required.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Exchange flow snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExchangeFlowsPro"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/exchange-flows \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nf = requests.get(\n    \"https://terminalfeed.io/api/pro/exchange-flows\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n    timeout=15,\n).json()\nprint(f\"Net flow: {f['aggregate']['net_flow_eth']} ETH ({f['aggregate']['bias']})\")\nfor ex in f['flows_by_exchange']:\n    print(f\"  {ex['exchange']}: net {ex['net_eth']} ETH\")"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const f = await fetch(\"https://terminalfeed.io/api/pro/exchange-flows\", {\n  headers: { Authorization: `Bearer ${TOKEN}` },\n}).then(r => r.json());\nconsole.log(\"Bias:\", f.aggregate.bias, \"Net:\", f.aggregate.net_flow_eth, \"ETH\");"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 3,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "API directory",
        "description": "Self-describing index of free and premium endpoints with pricing. Recommended first call for autonomous agents.",
        "responses": {
          "200": {
            "description": "Endpoint inventory.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/mcp": {
      "get": {
        "tags": [
          "free"
        ],
        "summary": "MCP server discovery info",
        "description": "Returns server name, MCP protocol version, supported methods, and a copy-paste claude_desktop_config.json snippet showing how to integrate the TerminalFeed MCP server with Claude Desktop using the mcp-remote stdio adapter.",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server info.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "free"
        ],
        "summary": "MCP JSON-RPC 2.0 endpoint",
        "description": "JSON-RPC 2.0 endpoint implementing the Model Context Protocol over HTTP. Exposes all 21 TerminalFeed tools (9 free + 9 premium + 3 payment) to any @modelcontextprotocol/sdk client. Methods: initialize, tools/list, tools/call, notifications/initialized. Premium tools require Authorization: Bearer tf_live_<64-char-hex> on the request; the bearer doubles as the MCP credential. Credits-remaining is surfaced via JSON-RPC result _meta.credits_remaining.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {
                    "type": [
                      "integer",
                      "string",
                      "null"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "initialize",
                      "tools/list",
                      "tools/call",
                      "notifications/initialized"
                    ]
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-pricing-credits": 0,
        "x-pricing-usd": 0,
        "x-mcp-protocol-version": "2024-11-05"
      }
    },
    "/api/pro/subscribe": {
      "post": {
        "tags": [
          "pro"
        ],
        "summary": "Create webhook subscription (push instead of poll)",
        "description": "Register a webhook URL to receive push deliveries every ~5 minutes. Each fire calls the subscribed /api/pro/* endpoint, HMAC-SHA256-signs the payload using the secret returned at creation, and POSTs to your URL. Per-token cap: 5 active subs. Webhook URL must be https and not resolve to private/loopback/link-local. Each fire costs 1 credit ($0.02). Subs auto-pause on insufficient_credits.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "webhook_url",
                  "endpoint"
                ],
                "properties": {
                  "webhook_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https public URL receiving deliveries"
                  },
                  "endpoint": {
                    "type": "string",
                    "enum": [
                      "sentiment",
                      "briefing",
                      "exchange-flows",
                      "agent-context",
                      "world-deltas",
                      "macro",
                      "crypto-deep",
                      "whales",
                      "correlation-matrix"
                    ],
                    "description": "Premium endpoint slug to monitor"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription created. Save the secret; it is returned only once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed (invalid_endpoint, https_required, private_or_local_hostname, url_too_long)."
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          },
          "429": {
            "description": "subscription_limit_reached. Cancel an existing sub before creating another."
          }
        },
        "x-pricing-credits": 0,
        "x-pricing-usd": 0,
        "x-fire-cost-credits": 1,
        "x-fire-cost-usd": 0.02,
        "x-fire-interval": "5 minutes",
        "x-license": "inference-only"
      }
    },
    "/api/pro/subscriptions": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "List owner's webhook subscriptions",
        "description": "Returns all active and paused webhook subs owned by the bearer. Secrets are NOT returned (saved only at creation).",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Array of subscription summaries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-pricing-credits": 0,
        "x-pricing-usd": 0
      }
    },
    "/api/pro/subscribe/{id}": {
      "delete": {
        "tags": [
          "pro"
        ],
        "summary": "Cancel a webhook subscription",
        "description": "Deletes the subscription. Bearer must own the sub. Subsequent cron ticks will not fire.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^wh_[a-f0-9]{16}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          },
          "403": {
            "description": "Forbidden: bearer does not own this subscription."
          },
          "404": {
            "description": "Not found."
          }
        },
        "x-pricing-credits": 0,
        "x-pricing-usd": 0
      }
    },
    "/api/pro/defi-tvl": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Composed DeFi TVL snapshot via DefiLlama (2 credits)",
        "description": "Top 50 DeFi protocols by total value locked, top 15 chains, by-category aggregates, and biggest gainers/losers over 24h and 7d. Each protocol entry includes 1h/24h/7d change %, category, chain, market cap, and FDV. Source: DefiLlama free public API. 30-min cache.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "DeFi TVL snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/defi-tvl \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nd = requests.get(\n    \"https://terminalfeed.io/api/pro/defi-tvl\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n).json()\nfor p in d['top_protocols'][:10]:\n    print(p['name'], p['tvl_usd'], p['change_1d_percent'])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const d = await fetch(\"https://terminalfeed.io/api/pro/defi-tvl\", {\n  headers: { Authorization: `Bearer ${TOKEN}` }\n}).then(r => r.json());\nconsole.log(\"Top category:\", d.by_category[0]);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 2,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/stablecoin-flows": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "Stablecoin net flows snapshot via DefiLlama (2 credits)",
        "description": "Top 20 stablecoins by circulating supply with 24h/7d/30d net change in USD and percent. Aggregate net flow across all 180+ tracked stablecoins, biggest growers and shrinkers, bias label (growing/shrinking/balanced). Source: DefiLlama stablecoins API. 1-hour cache.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Stablecoin flows snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/stablecoin-flows \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nd = requests.get(\n    \"https://terminalfeed.io/api/pro/stablecoin-flows\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n).json()\nprint(\"Net 24h:\", d['aggregate']['net_change_24h_usd'], d['aggregate']['bias_24h'])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const d = await fetch(\"https://terminalfeed.io/api/pro/stablecoin-flows\", {\n  headers: { Authorization: `Bearer ${TOKEN}` }\n}).then(r => r.json());\nconsole.log(\"USDT:\", d.stablecoins[0]);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 1,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    },
    "/api/pro/github-velocity": {
      "get": {
        "tags": [
          "pro"
        ],
        "summary": "GitHub trending repos + AI/ML focus + language mix (2 credits)",
        "description": "Top 30 repos created in the last 7 days sorted by stars, top 15 AI/ML-focused active repos (topic:llm + commits in last 30d), language and topic aggregates, AI/ML share of trending. Source: GitHub Search API. 30-min cache. Optional GITHUB_TOKEN Worker secret for higher upstream rate limit.",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "GitHub velocity snapshot.",
            "headers": {
              "X-Credits-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PremiumPaymentRequired"
          }
        },
        "x-codeSamples": [
          {
            "lang": "curl",
            "label": "curl",
            "source": "curl https://terminalfeed.io/api/pro/github-velocity \\n  -H \"Authorization: Bearer tf_live_<64-char-hex>\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import requests\nd = requests.get(\n    \"https://terminalfeed.io/api/pro/github-velocity\",\n    headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n).json()\nprint(\"AI/ML share %:\", d['aggregate']['ai_ml_share_percent'])"
          },
          {
            "lang": "JavaScript",
            "label": "JavaScript",
            "source": "const d = await fetch(\"https://terminalfeed.io/api/pro/github-velocity\", {\n  headers: { Authorization: `Bearer ${TOKEN}` }\n}).then(r => r.json());\nfor (const r of d.trending_repos.slice(0, 5)) console.log(r.full_name, r.stars);"
          }
        ],
        "x-pricing-credits": 2,
        "x-pricing-usd": 0.04,
        "x-composes-sources": 2,
        "x-license": "inference-only",
        "x-payment-required": true,
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.04"
          }
        }
      }
    }
  },
  "x-tagGroups": [
    {
      "name": "Free Tier",
      "tags": [
        "free"
      ]
    },
    {
      "name": "Premium Tier",
      "tags": [
        "pro",
        "payment"
      ]
    }
  ],
  "externalDocs": {
    "description": "Premium API for AI agents — full developer guide, payment flow, and cross-site bundle with TensorFeed.",
    "url": "https://terminalfeed.io/developers/agent-payments"
  }
}
