{
  "openapi": "3.1.0",
  "info": {
    "title": "whatsmypulse heart rate API",
    "version": "1.0.0",
    "description": "Heart rate zones, maximum heart rate equations and NHANES resting pulse percentiles. General wellness information, not medical advice. Every response includes sources and a disclaimer.",
    "contact": {
      "email": "hello@whatsmypulse.com",
      "url": "https://whatsmypulse.com/developers/"
    }
  },
  "servers": [
    {
      "url": "https://whatsmypulse.com"
    }
  ],
  "paths": {
    "/api/zones": {
      "get": {
        "operationId": "heartRateZones",
        "summary": "Five heart rate training zones",
        "parameters": [
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age in years",
            "schema": {
              "type": "integer",
              "minimum": 18,
              "maximum": 90
            }
          },
          {
            "name": "rest",
            "in": "query",
            "required": false,
            "description": "Resting heart rate (bpm); switches to the heart rate reserve (Karvonen) method",
            "schema": {
              "type": "integer",
              "minimum": 30,
              "maximum": 120
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "description": "Measured maximum heart rate (bpm); overrides the formula",
            "schema": {
              "type": "integer",
              "minimum": 100,
              "maximum": 230
            }
          },
          {
            "name": "formula",
            "in": "query",
            "required": false,
            "description": "Maximum heart rate equation",
            "schema": {
              "type": "string",
              "enum": [
                "tanaka",
                "fox",
                "gellish",
                "nes",
                "gulati"
              ],
              "default": "tanaka"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Zones",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (60 requests per minute per IP)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/max-heart-rate": {
      "get": {
        "operationId": "maxHeartRate",
        "summary": "Maximum heart rate by every published equation",
        "parameters": [
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age in years",
            "schema": {
              "type": "integer",
              "minimum": 18,
              "maximum": 90
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estimates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (60 requests per minute per IP)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/resting": {
      "get": {
        "operationId": "restingHeartRateReference",
        "summary": "NHANES resting pulse percentiles for an age group and sex",
        "parameters": [
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age in years",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 120
            }
          },
          {
            "name": "sex",
            "in": "query",
            "required": true,
            "description": "The survey tables are published by sex",
            "schema": {
              "type": "string",
              "enum": [
                "female",
                "male"
              ]
            }
          },
          {
            "name": "bpm",
            "in": "query",
            "required": false,
            "description": "A resting heart rate to place within the distribution",
            "schema": {
              "type": "integer",
              "minimum": 20,
              "maximum": 250
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reference percentiles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (60 requests per minute per IP)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Service status",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
