{
  "openapi": "3.1.0",
  "info": {
    "title": "New Site Index API",
    "description": "Real-time directory of newly launched websites. Query by category, country, date, domain, or keyword. No authentication required.",
    "version": "1.0.0",
    "contact": {
      "email": "hello@newsiteindex.com",
      "url": "https://newsiteindex.com"
    }
  },
  "servers": [
    { "url": "https://newsiteindex.com", "description": "Production" }
  ],
  "paths": {
    "/api/sites": {
      "get": {
        "operationId": "listSites",
        "summary": "List newly launched websites",
        "description": "Returns an array of recently detected websites. Filter by category, country, date, domain, or keyword search.",
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 200, "maximum": 500 }, "description": "Max records to return" },
          { "name": "skip", "in": "query", "schema": { "type": "integer", "default": 0 }, "description": "Records to skip (pagination)" },
          { "name": "sort", "in": "query", "schema": { "type": "string", "default": "-detected_at" }, "description": "Sort field. Prefix with - for descending. e.g. -detected_at, authority_score" },
          { "name": "category", "in": "query", "schema": { "type": "string", "enum": ["Tech","Business","Health","Entertainment","Education","Finance","Lifestyle","Other"] }, "description": "Filter by category" },
          { "name": "country", "in": "query", "schema": { "type": "string" }, "description": "ISO country code, e.g. US" },
          { "name": "date", "in": "query", "schema": { "type": "string", "format": "date" }, "description": "Filter to sites detected on a specific date (YYYY-MM-DD)" },
          { "name": "search", "in": "query", "schema": { "type": "string" }, "description": "Keyword search across domain, title, description, category" },
          { "name": "domain", "in": "query", "schema": { "type": "string" }, "description": "Exact domain lookup, e.g. example.com" },
          { "name": "slug", "in": "query", "schema": { "type": "string" }, "description": "Lookup by URL slug, e.g. example-com" }
        ],
        "responses": {
          "200": {
            "description": "Array of site objects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/Site" }
                }
              }
            }
          }
        }
      }
    },
    "/api/submit": {
      "post": {
        "operationId": "submitSite",
        "summary": "Submit a website for indexing",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/SubmitRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Site submitted successfully" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Site": {
        "type": "object",
        "properties": {
          "domain":          { "type": "string", "example": "example.com" },
          "title":           { "type": "string" },
          "description":     { "type": "string" },
          "category":        { "type": "string", "enum": ["Tech","Business","Health","Entertainment","Education","Finance","Lifestyle","Other"] },
          "country":         { "type": "string", "example": "US" },
          "detected_at":     { "type": "string", "format": "date-time" },
          "authority_score": { "type": "integer", "minimum": 0, "maximum": 100 },
          "has_ssl":         { "type": "boolean" },
          "tech_stack":      { "type": "array", "items": { "type": "string" } },
          "screenshot_url":  { "type": "string", "format": "uri" },
          "contact_email":   { "type": "string", "format": "email" },
          "slug":            { "type": "string" },
          "upvotes":         { "type": "integer" },
          "is_featured":     { "type": "boolean" }
        }
      },
      "SubmitRequest": {
        "type": "object",
        "required": ["domain"],
        "properties": {
          "domain":      { "type": "string" },
          "name":        { "type": "string" },
          "email":       { "type": "string", "format": "email" },
          "description": { "type": "string" },
          "category":    { "type": "string" }
        }
      }
    }
  }
}
