{
  "openapi": "3.1.0",
  "info": {
    "title": "PQ Scan API",
    "version": "2026-12-06.1",
    "summary": "Post-quantum TLS readiness checks and lab-tested fixes.",
    "description": "Free, read-only API behind PQ Scan. Checks use normal TLS handshakes only. Results are cached for 6 hours; a forced rescan is allowed every 5 minutes per host. Limits: about 20 new scans per minute per client and 10 per minute per site, about 120 reads of stored results per minute per client, and a shared budget per hosting network. Lists come in pages (leaderboard up to 100 rows, fixes up to 20). Automated browsers are refused; use a plain HTTP client. Bulk copying of results or the leaderboard is not allowed (see terms). Please cite https://pq-scan.com when you use results. For AI assistants, the MCP server at https://mcp.pq-scan.com/mcp wraps the same API.",
    "contact": {
      "name": "PQ Scan",
      "url": "https://pq-scan.com/about",
      "email": "hello@pq-scan.com"
    },
    "termsOfService": "https://pq-scan.com/terms"
  },
  "externalDocs": {
    "description": "Methodology",
    "url": "https://pq-scan.com/methodology"
  },
  "servers": [
    {
      "url": "https://pq-scan.com"
    }
  ],
  "tags": [
    {
      "name": "scan"
    },
    {
      "name": "fixes"
    }
  ],
  "paths": {
    "/api/scan": {
      "get": {
        "operationId": "scanDomain",
        "tags": [
          "scan"
        ],
        "summary": "Check a website (cached up to 6 hours)",
        "parameters": [
          {
            "name": "host",
            "in": "query",
            "required": true,
            "description": "Domain, optionally with a port (example.com or example.com:8443).",
            "schema": {
              "type": "string",
              "examples": [
                "example.com"
              ]
            }
          },
          {
            "name": "fresh",
            "in": "query",
            "required": false,
            "description": "1 forces a new check (at most every 5 minutes per host).",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scan result. Header x-cache tells hit, miss or stale; x-scan-age is the age in seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or non-public host.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The domain owner opted out of scanning.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The domain has no address records.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The site could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/latest": {
      "get": {
        "operationId": "latestScan",
        "tags": [
          "scan"
        ],
        "summary": "Latest stored result (never starts a scan)",
        "parameters": [
          {
            "name": "host",
            "in": "query",
            "required": true,
            "description": "Domain, optionally with a port (example.com or example.com:8443).",
            "schema": {
              "type": "string",
              "examples": [
                "example.com"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored scan result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or non-public host.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The domain owner opted out of scanning.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not checked yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/history": {
      "get": {
        "operationId": "scanHistory",
        "tags": [
          "scan"
        ],
        "summary": "Grade history for a host (newest first, up to 30)",
        "parameters": [
          {
            "name": "host",
            "in": "query",
            "required": true,
            "description": "Domain, optionally with a port (example.com or example.com:8443).",
            "schema": {
              "type": "string",
              "examples": [
                "example.com"
              ]
            }
          },
          {
            "name": "port",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 443
            }
          }
        ],
        "responses": {
          "200": {
            "description": "History rows.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/History"
                }
              }
            }
          },
          "400": {
            "description": "Invalid host.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/ssh": {
      "get": {
        "operationId": "checkSsh",
        "tags": [
          "scan"
        ],
        "summary": "SSH key exchange on port 22 (banner and KEXINIT only, never logs in)",
        "parameters": [
          {
            "name": "host",
            "in": "query",
            "required": true,
            "description": "Domain, optionally with a port (example.com or example.com:8443).",
            "schema": {
              "type": "string",
              "examples": [
                "example.com"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SSH check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SshCheck"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or non-public host.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The domain owner opted out of scanning.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/mail": {
      "get": {
        "operationId": "checkMail",
        "tags": [
          "scan"
        ],
        "summary": "Mail servers' STARTTLS key exchange (may be switched off)",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "description": "Domain, optionally with a port (example.com or example.com:8443).",
            "schema": {
              "type": "string",
              "examples": [
                "example.com"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Mail check result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or non-public host.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The domain owner opted out of scanning.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Email checks are not switched on.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/top": {
      "get": {
        "operationId": "topSites",
        "tags": [
          "scan"
        ],
        "summary": "Leaderboard: latest stored checks of a hand-picked list of well-known sites",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Rows per page (1 to 100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip. Use the response's next value.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rows.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Top"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/fixes": {
      "get": {
        "operationId": "listFixes",
        "tags": [
          "fixes"
        ],
        "summary": "Lab-tested fix recipes (Markdown body)",
        "parameters": [
          {
            "name": "finding",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "pq-kex-missing"
              ]
            }
          },
          {
            "name": "stack",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "nginx"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Rows per page (1 to 20).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip. Use the response's next value.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recipes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Fixes"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Try again in a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/methodology": {
      "get": {
        "operationId": "methodology",
        "tags": [
          "scan"
        ],
        "summary": "Grading rules and methodology version",
        "responses": {
          "200": {
            "description": "Rules.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Methodology"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Grade": {
        "type": [
          "string",
          "null"
        ],
        "enum": [
          "A+",
          "A",
          "B",
          "C",
          "D",
          "F",
          null
        ]
      },
      "Finding": {
        "type": "object",
        "required": [
          "id",
          "severity",
          "title"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable id; explained at /llms-full.txt and by the MCP tool explain_finding."
          },
          "axis": {
            "type": "string",
            "enum": [
              "confidentiality",
              "agility",
              "email",
              "ssh"
            ]
          },
          "severity": {
            "type": "string",
            "enum": [
              "risk",
              "attention",
              "info",
              "industry-not-ready",
              "pass"
            ]
          },
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "deadline": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "ScanResult": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "host",
          "port",
          "scannedAt",
          "grade",
          "tls"
        ],
        "properties": {
          "host": {
            "type": "string"
          },
          "port": {
            "type": "integer"
          },
          "scannedAt": {
            "type": "string",
            "format": "date-time"
          },
          "durationMs": {
            "type": "integer"
          },
          "grade": {
            "type": "object",
            "properties": {
              "overall": {
                "$ref": "#/components/schemas/Grade"
              },
              "confidentiality": {
                "$ref": "#/components/schemas/Grade"
              },
              "agility": {
                "$ref": "#/components/schemas/Grade"
              },
              "methodology": {
                "type": "string"
              },
              "findings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Finding"
                }
              }
            }
          },
          "tls": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "reachable": {
                "type": "boolean"
              },
              "pq": {
                "type": "string",
                "enum": [
                  "preferred",
                  "supported",
                  "none",
                  "unknown"
                ]
              },
              "browserGroup": {
                "type": [
                  "string",
                  "null"
                ],
                "examples": [
                  "X25519MLKEM768"
                ]
              },
              "browserVersion": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "versions": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "boolean",
                    "null"
                  ]
                }
              },
              "supportedGroups": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          },
          "chain": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "http": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "dns": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "stack": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "stack": {
                  "type": "string"
                },
                "edge": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "History": {
        "type": "object",
        "properties": {
          "host": {
            "type": "string"
          },
          "port": {
            "type": "integer"
          },
          "scans": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "at": {
                  "type": "string",
                  "format": "date-time"
                },
                "grade": {
                  "$ref": "#/components/schemas/Grade"
                },
                "pq": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "group": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "SshCheck": {
        "type": "object",
        "properties": {
          "host": {
            "type": "string"
          },
          "scannedAt": {
            "type": "string",
            "format": "date-time"
          },
          "ssh": {
            "type": "object",
            "properties": {
              "ok": {
                "type": "boolean"
              },
              "banner": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "kex": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "pqKex": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Top": {
        "type": "object",
        "properties": {
          "maxAgeDays": {
            "type": "integer"
          },
          "listed": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "next": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Offset of the next page, or null on the last page."
          },
          "source": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "host": {
                  "type": "string"
                },
                "category": {
                  "type": "string"
                },
                "grade": {
                  "$ref": "#/components/schemas/Grade"
                },
                "pq": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "group": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "scannedAt": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Fixes": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "next": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Offset of the next page, or null on the last page."
          },
          "recipes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "id": {
                  "type": "string"
                },
                "stack": {
                  "type": "string"
                },
                "finding": {
                  "type": "string"
                },
                "also_fixes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "title": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "body": {
                  "type": "string",
                  "description": "Markdown"
                },
                "testedOn": {
                  "type": "string"
                },
                "testedAt": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Methodology": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "rules": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}