{
  "openapi": "3.1.0",
  "info": {
    "title": "TokenMarkdown.com API",
    "version": "1.0.0",
    "description": "Sub-150ms headless web-to-markdown API and Model Context Protocol (MCP) server."
  },
  "servers": [
    {
      "url": "https://tokenmarkdown.com",
      "description": "Production Server"
    },
    {
      "url": "http://localhost:3000",
      "description": "Local Development Server"
    }
  ],
  "paths": {
    "/v1/extract": {
      "post": {
        "summary": "Extract clean markdown from URL",
        "description": "Strips ads, tracking scripts, and navbars from any URL and returns clean GitHub-Flavored Markdown with metadata.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": { "type": "string", "format": "uri" },
                  "include_images": { "type": "boolean", "default": true },
                  "include_links": { "type": "boolean", "default": true },
                  "max_length": { "type": "integer", "default": 100000 },
                  "selector": { "type": "string" },
                  "exclude_selectors": { "type": "array", "items": { "type": "string" } },
                  "format": { "type": "string", "enum": ["json", "raw", "xml", "markdown"], "default": "json" }
                },
                "required": ["url"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful extraction"
          },
          "400": {
            "description": "Invalid URL or SSRF block"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/v1/extract/batch": {
      "post": {
        "summary": "Parallel batch URL extraction",
        "description": "Concurrently extracts markdown from up to 10 URLs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "urls": { "type": "array", "items": { "type": "string", "format": "uri" }, "minItems": 1, "maxItems": 10 }
                },
                "required": ["urls"]
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Batch extraction results" }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": { "description": "Server health status" }
        }
      }
    }
  }
}
