{
  "openapi": "3.0.3",
  "info": {
    "title": "CryptoPulse24 Public API",
    "version": "1.0.0",
    "description": "Free public crypto data API. No API key required. Built for developers, traders, and AI tools.",
    "contact": {
      "name": "CryptoPulse24 Support",
      "email": "api@cryptopulse24.com",
      "url": "https://cryptopulse24.com/api-docs"
    },
    "license": {
      "name": "Free for non-commercial and commercial use under fair-use rate limits"
    }
  },
  "servers": [
    { "url": "https://cryptopulse24.com", "description": "Production" }
  ],
  "paths": {
    "/api/btc-price": {
      "get": {
        "summary": "Live Bitcoin price",
        "description": "Returns the current Bitcoin price in USD plus 24h change.",
        "operationId": "getBtcPrice",
        "responses": {
          "200": {
            "description": "Live BTC price.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/BtcPrice" }
              }
            }
          },
          "429": { "description": "Rate limit exceeded." }
        }
      }
    },
    "/api/fear-greed": {
      "get": {
        "summary": "Fear & Greed Index",
        "description": "Returns the current Crypto Fear & Greed Index (0-100).",
        "operationId": "getFearGreed",
        "responses": {
          "200": {
            "description": "Current Fear & Greed reading.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/FearGreed" }
              }
            }
          },
          "429": { "description": "Rate limit exceeded." }
        }
      }
    },
    "/api/market-summary": {
      "get": {
        "summary": "Global market summary",
        "description": "Returns a snapshot of total market cap, BTC dominance, 24h volume, and key prices.",
        "operationId": "getMarketSummary",
        "responses": {
          "200": {
            "description": "Aggregate market snapshot.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/MarketSummary" }
              }
            }
          },
          "429": { "description": "Rate limit exceeded." }
        }
      }
    },
    "/api/top-coins": {
      "get": {
        "summary": "Top 10 coins by market cap",
        "description": "Returns the top 10 coins by market cap with live prices and 24h changes.",
        "operationId": "getTopCoins",
        "responses": {
          "200": {
            "description": "Ranked list of top 10 coins.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TopCoins" }
              }
            }
          },
          "429": { "description": "Rate limit exceeded." }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BtcPrice": {
        "type": "object",
        "required": ["price", "currency", "change24h", "timestamp"],
        "properties": {
          "price":      { "type": "number", "example": 75247.32 },
          "currency":   { "type": "string", "example": "USD" },
          "change24h":  { "type": "number", "example": 1.23 },
          "timestamp":  { "type": "string", "format": "date-time" }
        }
      },
      "FearGreed": {
        "type": "object",
        "required": ["value", "classification", "timestamp"],
        "properties": {
          "value":          { "type": "integer", "minimum": 0, "maximum": 100, "example": 72 },
          "classification": { "type": "string", "example": "Greed", "enum": ["Extreme Fear", "Fear", "Neutral", "Greed", "Extreme Greed"] },
          "timestamp":      { "type": "string", "format": "date-time" }
        }
      },
      "MarketSummary": {
        "type": "object",
        "required": ["totalMarketCap", "btcDominance", "totalVolume24h", "fearGreed", "btcPrice", "ethPrice", "timestamp"],
        "properties": {
          "totalMarketCap": { "type": "string", "example": "2.8T" },
          "btcDominance":   { "type": "string", "example": "54.2%" },
          "totalVolume24h": { "type": "string", "example": "185B" },
          "fearGreed":      { "type": "integer", "example": 72 },
          "btcPrice":       { "type": "number", "example": 75247.32 },
          "ethPrice":       { "type": "number", "example": 2315.58 },
          "timestamp":      { "type": "string", "format": "date-time" }
        }
      },
      "Coin": {
        "type": "object",
        "required": ["rank", "symbol", "name", "price", "change24h"],
        "properties": {
          "rank":      { "type": "integer", "example": 1 },
          "symbol":    { "type": "string", "example": "BTC" },
          "name":      { "type": "string", "example": "Bitcoin" },
          "price":     { "type": "number", "example": 75247.32 },
          "change24h": { "type": "number", "example": 1.23 }
        }
      },
      "TopCoins": {
        "type": "object",
        "required": ["coins", "timestamp"],
        "properties": {
          "coins":     { "type": "array", "items": { "$ref": "#/components/schemas/Coin" } },
          "timestamp": { "type": "string", "format": "date-time" }
        }
      }
    }
  }
}
