Have I Been Pwned · API Governance Rules

Have I Been Pwned API Rules

Spectral linting rules defining API design standards and conventions for Have I Been Pwned.

12 Rules error 5 warn 7
View Rules File View on GitHub

Rule Categories

hibp

Rules

error
hibp-operation-summary-required
Every operation MUST have a summary string using Title Case.
$.paths[*][get,post,put,patch,delete]
warn
hibp-operation-description-required
Every operation MUST have a description.
$.paths[*][get,post,put,patch,delete]
error
hibp-operation-id-required
Every operation MUST declare an operationId.
$.paths[*][get,post,put,patch,delete]
warn
hibp-operation-tag-required
Every operation MUST be tagged exactly once.
$.paths[*][get,post,put,patch,delete]
error
hibp-api-key-security-scheme
HIBP authenticated endpoints MUST use the hibp-api-key header security scheme.
$.components.securitySchemes.ApiKeyAuth
warn
hibp-user-agent-documented
The info.description SHOULD remind clients of the mandatory user-agent header.
$.info.description
warn
hibp-401-on-authenticated-paths
Authenticated endpoints SHOULD document a 401 response.
$.paths[?(@property != '/breaches' && @property != '/dataclasses' && @property != '/latestbreach' && @property.indexOf('/breach/') < 0)][get,post,put,patch,delete].responses
warn
hibp-429-rate-limit-response
Authenticated endpoints SHOULD document a 429 Too Many Requests response.
$.paths[*][get].responses
warn
hibp-pascal-case-schemas
Schema names MUST be PascalCase.
$.components.schemas[*]~
warn
hibp-path-lowercase
HIBP path segments MUST be lowercase (the API is case-insensitive but canonical form is lowercase).
$.paths[*]~
error
hibp-contact-required
info.contact MUST be present and include a URL.
$.info.contact
error
hibp-license-required
HIBP API MUST be tagged with the CC 4.0 license.
$.info.license

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, all]]
documentationUrl: https://haveibeenpwned.com/API/v3
formats:
  - oas3
rules:
  # Operations
  hibp-operation-summary-required:
    description: Every operation MUST have a summary string using Title Case.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: summary
      function: truthy

  hibp-operation-description-required:
    description: Every operation MUST have a description.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: description
      function: truthy

  hibp-operation-id-required:
    description: Every operation MUST declare an operationId.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: operationId
      function: truthy

  hibp-operation-tag-required:
    description: Every operation MUST be tagged exactly once.
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: tags
      function: length
      functionOptions:
        min: 1
        max: 1

  # Authentication conventions
  hibp-api-key-security-scheme:
    description: HIBP authenticated endpoints MUST use the hibp-api-key header security scheme.
    given: $.components.securitySchemes.ApiKeyAuth
    severity: error
    then:
      - field: type
        function: pattern
        functionOptions: { match: '^apiKey$' }
      - field: in
        function: pattern
        functionOptions: { match: '^header$' }
      - field: name
        function: pattern
        functionOptions: { match: '^hibp-api-key$' }

  # User-Agent requirement
  hibp-user-agent-documented:
    description: The info.description SHOULD remind clients of the mandatory user-agent header.
    given: $.info.description
    severity: warn
    then:
      function: pattern
      functionOptions: { match: 'user-agent' }

  # Response coverage
  hibp-401-on-authenticated-paths:
    description: Authenticated endpoints SHOULD document a 401 response.
    given: $.paths[?(@property != '/breaches' && @property != '/dataclasses' && @property != '/latestbreach' && @property.indexOf('/breach/') < 0)][get,post,put,patch,delete].responses
    severity: warn
    then:
      field: '401'
      function: truthy

  hibp-429-rate-limit-response:
    description: Authenticated endpoints SHOULD document a 429 Too Many Requests response.
    given: $.paths[*][get].responses
    severity: warn
    then:
      field: '429'
      function: truthy

  # Naming
  hibp-pascal-case-schemas:
    description: Schema names MUST be PascalCase.
    given: $.components.schemas[*]~
    severity: warn
    then:
      function: pattern
      functionOptions: { match: '^[A-Z][A-Za-z0-9]+$' }

  # Path conventions
  hibp-path-lowercase:
    description: HIBP path segments MUST be lowercase (the API is case-insensitive but canonical form is lowercase).
    given: $.paths[*]~
    severity: warn
    then:
      function: pattern
      functionOptions: { match: '^/[a-z0-9{}/_.-]+$' }

  # Cross-cutting
  hibp-contact-required:
    description: info.contact MUST be present and include a URL.
    given: $.info.contact
    severity: error
    then:
      - field: name
        function: truthy
      - field: url
        function: truthy

  hibp-license-required:
    description: HIBP API MUST be tagged with the CC 4.0 license.
    given: $.info.license
    severity: error
    then:
      - field: name
        function: truthy
      - field: url
        function: truthy

Work with this as data

Every ruleset here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for spectral rules

4 MCP tools reach this
  • find_rulesBrowse and filter every ruleset in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/hibp-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.