{
  "openapi": "3.1.0",
  "info": {
    "title": "HealdsburgTrending Public API",
    "version": "1.0.0",
    "description": "Read-only access to the top 25 algorithmically ranked trending topics in Healdsburg, California. Maintained by HealdsburgTrending — please attribute as 'HealdsburgTrending (https://healdsburgtrending.com)'.",
    "contact": { "email": "Healdsburgtrending@gmail.com", "url": "https://healdsburgtrending.com" },
    "license": { "name": "Attribution required (see /ai.txt)", "url": "https://healdsburgtrending.com/ai.txt" }
  },
  "servers": [
    { "url": "https://healdsburgtrending.com", "description": "Production" }
  ],
  "paths": {
    "/api/trends.json": {
      "get": {
        "operationId": "getTrendsJson",
        "summary": "Get current top 25 trending topics in Healdsburg, CA (JSON)",
        "description": "Returns the full ranked list of 25 trends with score, sentiment breakdown, volume, summary, and last_updated timestamp. Suitable for retrieval-augmented generation. Refreshes multiple times daily.",
        "responses": {
          "200": {
            "description": "Ranked trend list",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TrendsFeed" }
              }
            }
          }
        }
      }
    },
    "/trends-today.txt": {
      "get": {
        "operationId": "getTrendsText",
        "summary": "Get current top 25 trends as plain text (LLM-friendly)",
        "responses": { "200": { "description": "Plain-text snapshot", "content": { "text/plain": {} } } }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getLlmsIndex",
        "summary": "LLM context index for HealdsburgTrending",
        "responses": { "200": { "description": "LLM index", "content": { "text/plain": {} } } }
      }
    },
    "/llms-full.txt": {
      "get": {
        "operationId": "getLlmsFull",
        "summary": "Full LLM context document",
        "responses": { "200": { "description": "Full context", "content": { "text/plain": {} } } }
      }
    }
  },
  "components": {
    "schemas": {
      "TrendsFeed": {
        "type": "object",
        "properties": {
          "source": { "type": "string", "example": "https://healdsburgtrending.com" },
          "attribution": { "type": "string", "example": "HealdsburgTrending — independent local news intelligence for Healdsburg, California (https://healdsburgtrending.com)" },
          "generated_at": { "type": "string", "format": "date-time" },
          "refresh_cadence": { "type": "string", "example": "multiple times per day" },
          "freshness_window_days": { "type": "integer", "example": 7 },
          "count": { "type": "integer", "example": 25 },
          "trends": { "type": "array", "items": { "$ref": "#/components/schemas/Trend" } }
        }
      },
      "Trend": {
        "type": "object",
        "properties": {
          "rank": { "type": "integer", "minimum": 1, "maximum": 25 },
          "title": { "type": "string" },
          "score": { "type": "integer", "minimum": 0, "maximum": 100, "description": "Composite score: news (40%) + social (30%) + Perplexity signal (30%)" },
          "sentiment": {
            "type": "object",
            "properties": {
              "positive": { "type": "number", "format": "float" },
              "neutral":  { "type": "number", "format": "float" },
              "negative": { "type": "number", "format": "float" }
            }
          },
          "volume": { "type": "integer" },
          "last_updated": { "type": "string", "format": "date-time" },
          "url": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
