{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentNews",
    "version": "1.0.0",
    "description": "AgentNews — Hacker News + Guardian news API with x402 micropayments. $0.001 USDC per request."
  },
  "servers": [
    { "url": "https://news.memoryapi.org", "description": "Production" }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Service status",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "service": { "type": "string" }, "port": { "type": "number" } } } } }
          }
        }
      }
    },
    "/x402/news/top": {
      "get": {
        "summary": "Hacker News top stories",
        "operationId": "getTopNews",
        "x-price": "$0.001 USDC",
        "parameters": [
          { "name": "type", "in": "query", "schema": { "type": "string", "enum": ["top", "new", "best", "ask", "show"], "default": "top" }, "description": "Story type" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 30 }, "description": "Number of stories" }
        ],
        "responses": {
          "200": {
            "description": "Stories list",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "type": { "type": "string" }, "count": { "type": "integer" }, "stories": { "type": "array", "items": { "type": "object" } }, "source": { "type": "string" } } } } }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/x402/news/search": {
      "get": {
        "summary": "Search The Guardian",
        "operationId": "searchGuardian",
        "x-price": "$0.001 USDC",
        "parameters": [
          { "name": "q", "in": "query", "schema": { "type": "string", "default": "artificial intelligence" }, "description": "Search query" },
          { "name": "section", "in": "query", "schema": { "type": "string", "enum": ["technology", "science", "business", "world", "politics"] }, "description": "Section filter" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 25 }, "description": "Results count" },
          { "name": "date_from", "in": "query", "schema": { "type": "string", "format": "date" }, "description": "Filter from date (YYYY-MM-DD)" }
        ],
        "responses": {
          "200": {
            "description": "Articles list",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "query": { "type": "string" }, "section": { "type": "string" }, "count": { "type": "integer" }, "total": { "type": "integer" }, "articles": { "type": "array", "items": { "type": "object" } }, "source": { "type": "string" } } } } }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/x402/news/trending": {
      "get": {
        "summary": "Trending news (HN + Guardian)",
        "operationId": "getTrending",
        "x-price": "$0.001 USDC",
        "parameters": [
          { "name": "topic", "in": "query", "schema": { "type": "string", "enum": ["ai", "crypto", "science", "politics", "tech"], "default": "tech" }, "description": "Topic filter" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 30 }, "description": "Number of items" }
        ],
        "responses": {
          "200": {
            "description": "Trending items",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "topic": { "type": "string" }, "count": { "type": "integer" }, "items": { "type": "array", "items": { "type": "object" } }, "source": { "type": "string" } } } } }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "MCP server info",
        "operationId": "mcpInfo",
        "security": [],
        "responses": { "200": { "description": "MCP server metadata" } }
      },
      "post": {
        "summary": "MCP tool call",
        "operationId": "mcpCall",
        "security": [],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object" } } }
        },
        "responses": { "200": { "description": "MCP JSON-RPC response" } }
      }
    }
  }
}
