{
  "openapi": "3.0.3",
  "info": {
    "title": "PaperLeaks API",
    "description": "Public REST API for PaperLeaks.in — 22 Years of Exam Paper Leaks in India (2004–2026). Every incident is backed by source reporting.",
    "version": "1.0.0",
    "x-api-version": "1.0.0",
    "x-deprecation-policy": "Breaking changes are introduced only with major version increments (/v2/). Deprecated endpoints are announced 6 months in advance with RFC 8594 Sunset headers.",
    "contact": {
      "name": "Akash Priyadarshi",
      "email": "akash.priyadarshi9100backup@gmail.com",
      "url": "https://paperleaks.vercel.app"
    }
  },
  "servers": [
    {
      "url": "https://paperleaks.vercel.app",
      "description": "Production server"
    }
  ],
  "paths": {
    "/api/v1/incidents": {
      "get": {
        "operationId": "getIncidentsV1",
        "summary": "List all documented paper leak incidents (v1)",
        "description": "Returns all 110 documented exam fraud and paper leak cases across India with full metadata, arrests, convictions, and original source citations.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Filter incidents by Indian state or union territory (e.g. Bihar, Rajasthan, Uttar Pradesh)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by confirmation status",
            "schema": {
              "type": "string",
              "enum": ["Confirmed", "Alleged", "Suspected", "Denied"]
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "Filter by 4-digit discovery year (e.g. 2024)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of incidents to return",
            "schema": {
              "type": "integer",
              "default": 110,
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved incident dataset",
            "headers": {
              "RateLimit-Limit": {
                "description": "The number of allowed requests in the current period",
                "schema": { "type": "integer" }
              },
              "RateLimit-Remaining": {
                "description": "The number of remaining requests in the current period",
                "schema": { "type": "integer" }
              },
              "RateLimit-Reset": {
                "description": "The number of seconds until the rate limit resets",
                "schema": { "type": "integer" }
              },
              "X-API-Version": {
                "description": "Active API version",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying",
                "schema": { "type": "integer" }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    },
    "/api/incidents": {
      "get": {
        "operationId": "getIncidents",
        "summary": "List all documented paper leak incidents (legacy)",
        "description": "Returns all 110 documented exam fraud and paper leak cases across India.",
        "responses": {
          "200": {
            "description": "Successfully retrieved incident dataset",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentsResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Incident": {
        "type": "object",
        "required": [
          "incident_id",
          "exam_name",
          "date",
          "state",
          "leak_status",
          "source_url"
        ],
        "properties": {
          "incident_id": {
            "type": "string",
            "description": "Unique identifier for the leak record",
            "example": "PL-0001"
          },
          "exam_name": {
            "type": "string",
            "description": "Name of the compromised examination",
            "example": "NEET-UG 2024"
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date when leak or fraud was discovered (YYYY-MM-DD)",
            "example": "2024-05-05"
          },
          "state": {
            "type": "string",
            "description": "Indian state or union territory where the incident occurred",
            "example": "Bihar"
          },
          "area": {
            "type": "string",
            "description": "Specific city or district",
            "example": "Patna"
          },
          "conducting_body": {
            "type": "string",
            "description": "Examination board or agency responsible",
            "example": "National Testing Agency (NTA)"
          },
          "leak_status": {
            "type": "string",
            "enum": ["Confirmed", "Alleged", "Suspected", "Denied"],
            "description": "Official confirmation status of the paper leak",
            "example": "Confirmed"
          },
          "aspirants_affected": {
            "type": "string",
            "description": "Estimated candidate count impacted",
            "example": "2400000"
          },
          "arrests": {
            "type": "string",
            "description": "Total arrests made in connection",
            "example": "40"
          },
          "convictions": {
            "type": "string",
            "description": "Total convictions secured",
            "example": "0"
          },
          "source_url": {
            "type": "string",
            "format": "uri",
            "description": "Link to primary journalistic source",
            "example": "https://www.thehindu.com"
          }
        }
      },
      "IncidentsResponse": {
        "type": "object",
        "required": ["success", "count", "data"],
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "version": {
            "type": "string",
            "example": "v1"
          },
          "count": {
            "type": "integer",
            "example": 110
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Incident"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error", "code", "message"],
        "properties": {
          "error": {
            "type": "string",
            "description": "High level error category",
            "example": "Not Found"
          },
          "code": {
            "type": "string",
            "description": "Machine readable error code",
            "example": "NOT_FOUND"
          },
          "message": {
            "type": "string",
            "description": "Human readable explanation of the failure",
            "example": "The requested API endpoint does not exist."
          },
          "resolution": {
            "type": "string",
            "description": "Suggested action to resolve the issue",
            "example": "Check the OpenAPI specification at /openapi.json for valid endpoints."
          }
        }
      }
    }
  }
}
