{
  "openapi": "3.1.0",
  "info": {
    "title": "Glitchwire Public API",
    "version": "1.0.0",
    "description": "Machine-queryable interface to Glitchwire's independent technology journalism. All content is public; no authentication required. Attribution to Glitchwire (glitchwire.com) with a link to the article is requested when content is cited. An MCP server offering the same data as tool calls is available at https://glitchwire.com/mcp (server card: https://glitchwire.com/.well-known/mcp/server-card.json).",
    "contact": { "email": "contact@glitchwire.com", "url": "https://glitchwire.com" }
  },
  "servers": [{ "url": "https://glitchwire.com" }],
  "paths": {
    "/api/articles": {
      "get": {
        "operationId": "listArticles",
        "summary": "Search or list articles (newest first)",
        "description": "Full-text search over title and excerpt of every published article. Omit `q` and `category` to get the latest articles. Each result includes `markdown_url`, a clean ad-free markdown version of the full article.",
        "parameters": [
          { "name": "q", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Search terms, AND-matched against title and excerpt" },
          { "name": "category", "in": "query", "required": false, "schema": { "type": "string", "enum": ["AI", "Crypto", "Tech", "Science", "Energy", "Policy", "Finance", "Security", "Gadgets", "Culture"] }, "description": "Case-insensitive category filter" },
          { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "default": 20, "maximum": 50, "minimum": 1 } },
          { "name": "offset", "in": "query", "required": false, "schema": { "type": "integer", "default": 0, "minimum": 0 } }
        ],
        "responses": {
          "200": {
            "description": "Matching articles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": { "type": "integer", "description": "Total matches before pagination" },
                    "count": { "type": "integer", "description": "Number of articles in this page" },
                    "offset": { "type": "integer" },
                    "articles": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Article" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/popular": {
      "get": {
        "operationId": "popularArticles",
        "summary": "Most-viewed article slugs",
        "parameters": [
          { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "default": 5, "maximum": 10 } }
        ],
        "responses": {
          "200": {
            "description": "Top viewed articles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "articles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "slug": { "type": "string" },
                          "count": { "type": "integer" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Article": {
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "url": { "type": "string", "format": "uri", "description": "Canonical article page" },
          "markdown_url": { "type": "string", "format": "uri", "description": "Clean, ad-free markdown version of the full article" },
          "excerpt": { "type": "string" },
          "categories": { "type": "array", "items": { "type": "string" } },
          "date": { "type": "string", "description": "Display date, e.g. 'August 6, 2026'" },
          "author": { "type": "string", "description": "Desk byline" },
          "image": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
