{
  "openapi": "3.1.0",
  "info": {
    "title": "DefenceLevel public API",
    "version": "1.0.0",
    "description": "Public, read-only data of the DefenceLevel Index: the current DEFCON level and the daily levels. Data licence: CC BY 4.0, cite \"DefenceLevel Index (defencelevel.com)\". Methodology: https://defencelevel.com/index/methodology. Responses are cached for a few minutes and can be read from any website (CORS).",
    "contact": {
      "name": "DefenceLevel",
      "email": "info@defencelevel.com",
      "url": "https://defencelevel.com"
    },
    "license": {
      "name": "CC BY 4.0 (data)",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "externalDocs": {
    "description": "Embed the Index: badge, public data, licence and attribution",
    "url": "https://defencelevel.com/index/api"
  },
  "servers": [
    {
      "url": "https://defencelevel.com"
    }
  ],
  "paths": {
    "/api/status": {
      "get": {
        "operationId": "getCurrentLevel",
        "summary": "Current DEFCON level",
        "description": "Recalculated after every automatic collection (about every 30 minutes) on the last 24 hours; raised immediately when an alert at a more severe level is sent.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the texts",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "de",
                "es",
                "fr",
                "it"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current level ({\"defcon\": null} before the first calculation)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "defcon": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 5,
                      "description": "DEFCON level: 5 = low risk, 1 = critical risk"
                    },
                    "label": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time",
                      "description": "UTC"
                    },
                    "exploited": {
                      "type": "integer",
                      "description": "Actively exploited vulnerabilities in the latest calculation"
                    },
                    "urgent_today": {
                      "type": "integer",
                      "description": "Immediate alerts (DEFCON 1–2) since 00:00 UTC"
                    },
                    "stats": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "observations": {
                          "type": "integer",
                          "description": "Reports collected from the sources in the last 24 hours"
                        },
                        "evaluated": {
                          "type": "integer",
                          "description": "Vulnerabilities evaluated in the last 24 hours"
                        },
                        "selected": {
                          "type": "integer",
                          "description": "Vulnerabilities selected for the briefing"
                        },
                        "noise": {
                          "type": "integer",
                          "description": "Widely discussed stories classified as noise"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameter (the message lists the allowed values)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/badge.svg": {
      "get": {
        "operationId": "getBadge",
        "summary": "Embeddable badge with the current level",
        "description": "SVG image (232 × 64) with the current DEFCON level and its name, attribution included. Embed it with a link to the Index: see /index/api.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the texts",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "de",
                "es",
                "fr",
                "it"
              ],
              "default": "en"
            }
          },
          {
            "name": "theme",
            "in": "query",
            "required": false,
            "description": "Colours for a dark or light background",
            "schema": {
              "type": "string",
              "enum": [
                "dark",
                "light"
              ],
              "default": "dark"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Badge",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameter (the message lists the allowed values)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/trend": {
      "get": {
        "operationId": "getDailyLevels",
        "summary": "Daily levels of the DefenceLevel Index",
        "description": "One level per calendar day in UTC: the level set at 05:00 UTC with the daily briefing. Includes summary figures on fixed windows (last 30 days).",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "enum": [
                30,
                90,
                365
              ],
              "default": 30
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv",
                "atom"
              ],
              "default": "json"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the Atom feed",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "de",
                "es",
                "fr",
                "it"
              ],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Daily levels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "period": {
                      "type": "integer"
                    },
                    "days": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "day": {
                            "type": "string",
                            "format": "date"
                          },
                          "defcon": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 5,
                            "description": "DEFCON level: 5 = low risk, 1 = critical risk"
                          },
                          "observations": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "description": "Reports collected from the sources that day"
                          },
                          "selected": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "description": "Vulnerabilities selected for the briefing that day"
                          },
                          "peak": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "peak_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "HH:MM UTC"
                          }
                        }
                      }
                    },
                    "counts": {
                      "type": "object",
                      "description": "Number of days at each DEFCON level in the period",
                      "properties": {
                        "1": {
                          "type": "integer"
                        },
                        "2": {
                          "type": "integer"
                        },
                        "3": {
                          "type": "integer"
                        },
                        "4": {
                          "type": "integer"
                        },
                        "5": {
                          "type": "integer"
                        }
                      }
                    },
                    "kpi": {
                      "type": "object",
                      "description": "Summary figures on fixed windows, whatever the period",
                      "properties": {
                        "severe30": {
                          "type": "integer",
                          "description": "Days at DEFCON 1 or 2 in the last 30 days"
                        },
                        "severePrev30": {
                          "type": "integer",
                          "description": "Days at DEFCON 1 or 2 in the 30 days before"
                        },
                        "lastSevere": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "description": "Last day at DEFCON 1 or 2",
                          "properties": {
                            "day": {
                              "type": "string",
                              "format": "date"
                            },
                            "defcon": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5,
                              "description": "DEFCON level: 5 = low risk, 1 = critical risk"
                            }
                          }
                        },
                        "exploited30": {
                          "type": "integer",
                          "description": "Vulnerabilities added to the CISA KEV catalogue (actively exploited) in the last 30 days"
                        }
                      }
                    },
                    "kev_months": {
                      "type": "array",
                      "description": "Recent vulnerabilities (CVE of the year of addition or the year before) added each month to the CISA KEV catalogue",
                      "items": {
                        "type": "object",
                        "properties": {
                          "month": {
                            "type": "string",
                            "description": "YYYY-MM"
                          },
                          "n": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/atom+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameter (the message lists the allowed values)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/og": {
      "get": {
        "operationId": "getPreviewImage",
        "summary": "Preview image (1200×630 PNG) with the current level and the last 30 days",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of the texts",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "de",
                "es",
                "fr",
                "it"
              ],
              "default": "en"
            }
          },
          {
            "name": "d",
            "in": "query",
            "required": false,
            "description": "Day (YYYY-MM-DD), only to refresh caches",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PNG image",
            "content": {
              "image/png": {}
            }
          },
          "308": {
            "description": "Redirect to the canonical address when other parameters are present"
          }
        }
      }
    }
  }
}
