{
  "openapi": "3.0.3",
  "info": {
    "title": "WIMSTA Formula Registry & Calculation API",
    "version": "2026.08.11",
    "description": "A machine-readable registry of published body-composition and energy-expenditure formulas (body fat, BMI, waist-to-height ratio, maximum heart rate, basal metabolic rate). Each record gives the equation, coefficients, units, inputs, derivation sample, reported error, limitations and the primary source. Query it by URL parameter (/api/formulas?id=…, ?category=…) or download it whole (/api/registry.json). The Calculation API (/api/calc/{calculator}) returns the honest range for your own measurements, computed with the same functions as the wimsta.com calculators. No authentication, no API key, open CORS. Results are estimates for general information, not medical advice. Data licensed CC BY 4.0 - credit \"WIMSTA (wimsta.com)\" with a link.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "WIMSTA",
      "url": "https://wimsta.com/registry/",
      "email": "hello@wimsta.com"
    },
    "x-logo": {
      "url": "https://wimsta.com/wimsta-icon-512.png"
    }
  },
  "externalDocs": {
    "description": "Registry documentation",
    "url": "https://wimsta.com/registry/"
  },
  "servers": [
    {
      "url": "https://wimsta.com"
    }
  ],
  "paths": {
    "/api/registry.json": {
      "get": {
        "operationId": "getRegistry",
        "summary": "Get the full formula registry",
        "description": "Returns every formula with its coefficients and primary source. Static and cacheable (Cache-Control: max-age=3600).",
        "responses": {
          "200": {
            "description": "The formula registry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Registry"
                }
              }
            }
          }
        },
        "tags": [
          "Registry"
        ]
      }
    },
    "/api/formulas.json": {
      "get": {
        "operationId": "listFormulas",
        "summary": "List formula ids",
        "description": "Every formula's id, name, category and the URL of its record.",
        "responses": {
          "200": {
            "description": "Formula index",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "registry_version": {
                      "type": "string"
                    },
                    "license": {
                      "type": "string"
                    },
                    "attribution_notice": {
                      "type": "string"
                    },
                    "formula_count": {
                      "type": "integer"
                    },
                    "formulas": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Registry"
        ]
      }
    },
    "/api/formulas/{id}.json": {
      "get": {
        "operationId": "getFormula",
        "summary": "Get one formula by id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Formula id from /api/formulas.json",
            "schema": {
              "type": "string",
              "example": "cun-bae"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One formula",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "registry_version": {
                      "type": "string"
                    },
                    "license": {
                      "type": "string"
                    },
                    "attribution_notice": {
                      "type": "string"
                    },
                    "formula": {
                      "$ref": "#/components/schemas/Formula"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown id"
          }
        },
        "tags": [
          "Registry"
        ]
      }
    },
    "/api/formulas": {
      "get": {
        "operationId": "queryFormulas",
        "summary": "Query the registry by id or category",
        "description": "With `id` — one formula (same body as /api/formulas/{id}.json). With `category` — all formulas of that category. Without parameters — the index of ids.",
        "tags": [
          "Registry"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "description": "Formula id",
            "schema": {
              "type": "string",
              "example": "cun-bae"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category id",
            "schema": {
              "type": "string",
              "enum": [
                "body-fat",
                "body-fat-ranges",
                "bmi",
                "waist-to-height",
                "max-heart-rate",
                "bmr"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One formula, a category, or the index",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "registry_version": {
                      "type": "string"
                    },
                    "license": {
                      "type": "string"
                    },
                    "attribution_notice": {
                      "type": "string"
                    },
                    "formula": {
                      "$ref": "#/components/schemas/Formula"
                    },
                    "formulas": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc": {
      "get": {
        "operationId": "listCalculators",
        "summary": "List calculators and their parameters",
        "tags": [
          "Calculation"
        ],
        "responses": {
          "200": {
            "description": "Calculators",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/bmi": {
      "get": {
        "operationId": "calcBmi",
        "summary": "BMI as a range",
        "description": "Classic BMI and Trefethen BMI, WHO band.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "weight_kg",
            "in": "query",
            "required": true,
            "description": "Body weight, kg",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 350,
              "example": 80
            }
          },
          {
            "name": "height_cm",
            "in": "query",
            "required": true,
            "description": "Height, cm",
            "schema": {
              "type": "number",
              "minimum": 100,
              "maximum": 250,
              "example": 180
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/body-fat": {
      "get": {
        "operationId": "calcBodyFat",
        "summary": "Body fat % as a range",
        "description": "Every validated formula your measurements allow (Deurenberg, CUN-BAE, US Navy, RFM, Covert Bailey) and the Gallagher category. Give at least weight_kg+age, or waist_cm, or the US Navy set.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "sex",
            "in": "query",
            "required": true,
            "description": "Sex",
            "schema": {
              "type": "string",
              "enum": [
                "female",
                "male"
              ],
              "example": "female"
            }
          },
          {
            "name": "height_cm",
            "in": "query",
            "required": true,
            "description": "Height, cm",
            "schema": {
              "type": "number",
              "minimum": 100,
              "maximum": 250,
              "example": 180
            }
          },
          {
            "name": "weight_kg",
            "in": "query",
            "required": false,
            "description": "Body weight, kg",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 350,
              "example": 80
            }
          },
          {
            "name": "age",
            "in": "query",
            "required": false,
            "description": "Age, years (18+)",
            "schema": {
              "type": "number",
              "minimum": 18,
              "maximum": 100,
              "example": 40
            }
          },
          {
            "name": "waist_cm",
            "in": "query",
            "required": false,
            "description": "Natural waist, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 45,
              "maximum": 160
            }
          },
          {
            "name": "abdomen_cm",
            "in": "query",
            "required": false,
            "description": "Abdomen at the navel (US Navy, men), cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 50,
              "maximum": 170
            }
          },
          {
            "name": "neck_cm",
            "in": "query",
            "required": false,
            "description": "Neck, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 60
            }
          },
          {
            "name": "hip_cm",
            "in": "query",
            "required": false,
            "description": "Hips, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 60,
              "maximum": 180
            }
          },
          {
            "name": "wrist_cm",
            "in": "query",
            "required": false,
            "description": "Wrist, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 10,
              "maximum": 25
            }
          },
          {
            "name": "forearm_cm",
            "in": "query",
            "required": false,
            "description": "Forearm, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 15,
              "maximum": 45
            }
          },
          {
            "name": "thigh_cm",
            "in": "query",
            "required": false,
            "description": "Thigh, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 30,
              "maximum": 90
            }
          },
          {
            "name": "calf_cm",
            "in": "query",
            "required": false,
            "description": "Calf, cm (optional)",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 60
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/bmr": {
      "get": {
        "operationId": "calcBmr",
        "summary": "Basal metabolic rate as a range",
        "description": "Mifflin–St Jeor, Harris–Benedict 1984/1919, WHO/FAO, Katch–McArdle (with body_fat_pct). kcal/day.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "sex",
            "in": "query",
            "required": true,
            "description": "Sex",
            "schema": {
              "type": "string",
              "enum": [
                "female",
                "male"
              ],
              "example": "female"
            }
          },
          {
            "name": "weight_kg",
            "in": "query",
            "required": true,
            "description": "Body weight, kg",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 350,
              "example": 80
            }
          },
          {
            "name": "height_cm",
            "in": "query",
            "required": true,
            "description": "Height, cm",
            "schema": {
              "type": "number",
              "minimum": 100,
              "maximum": 250,
              "example": 180
            }
          },
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age, years (18+)",
            "schema": {
              "type": "number",
              "minimum": 18,
              "maximum": 100,
              "example": 40
            }
          },
          {
            "name": "body_fat_pct",
            "in": "query",
            "required": false,
            "description": "Body fat, % (optional; adds Katch–McArdle)",
            "schema": {
              "type": "number",
              "minimum": 3,
              "maximum": 65
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/tdee": {
      "get": {
        "operationId": "calcTdee",
        "summary": "Total daily energy expenditure as a range",
        "description": "BMR range × activity multiplier. kcal/day.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "sex",
            "in": "query",
            "required": true,
            "description": "Sex",
            "schema": {
              "type": "string",
              "enum": [
                "female",
                "male"
              ],
              "example": "female"
            }
          },
          {
            "name": "weight_kg",
            "in": "query",
            "required": true,
            "description": "Body weight, kg",
            "schema": {
              "type": "number",
              "minimum": 20,
              "maximum": 350,
              "example": 80
            }
          },
          {
            "name": "height_cm",
            "in": "query",
            "required": true,
            "description": "Height, cm",
            "schema": {
              "type": "number",
              "minimum": 100,
              "maximum": 250,
              "example": 180
            }
          },
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age, years (18+)",
            "schema": {
              "type": "number",
              "minimum": 18,
              "maximum": 100,
              "example": 40
            }
          },
          {
            "name": "activity",
            "in": "query",
            "required": true,
            "description": "Activity level",
            "schema": {
              "type": "string",
              "enum": [
                "sedentary",
                "light",
                "moderate",
                "extra",
                "extreme"
              ],
              "example": "moderate"
            }
          },
          {
            "name": "body_fat_pct",
            "in": "query",
            "required": false,
            "description": "Body fat, % (optional; adds Katch–McArdle)",
            "schema": {
              "type": "number",
              "minimum": 3,
              "maximum": 65
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/max-heart-rate": {
      "get": {
        "operationId": "calcMaxHeartRate",
        "summary": "Maximum heart rate as a range",
        "description": "Nine published formulas, plus five %HRmax training zones from the Gulati (women) / Tanaka anchor. bpm.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "age",
            "in": "query",
            "required": true,
            "description": "Age, years (18+)",
            "schema": {
              "type": "number",
              "minimum": 18,
              "maximum": 100,
              "example": 40
            }
          },
          {
            "name": "sex",
            "in": "query",
            "required": false,
            "description": "Sex",
            "schema": {
              "type": "string",
              "enum": [
                "female",
                "male"
              ],
              "example": "female"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/calc/waist-to-height": {
      "get": {
        "operationId": "calcWaistToHeight",
        "summary": "Waist-to-height ratio",
        "description": "Ratio, Ashwell zone and the healthy waist range for this height.",
        "tags": [
          "Calculation"
        ],
        "parameters": [
          {
            "name": "waist_cm",
            "in": "query",
            "required": true,
            "description": "Waist, cm",
            "schema": {
              "type": "number",
              "minimum": 45,
              "maximum": 160,
              "example": 80
            }
          },
          {
            "name": "height_cm",
            "in": "query",
            "required": true,
            "description": "Height, cm",
            "schema": {
              "type": "number",
              "minimum": 100,
              "maximum": 250,
              "example": 180
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Registry": {
        "type": "object",
        "required": [
          "registry_version",
          "license",
          "formulas"
        ],
        "properties": {
          "registry_version": {
            "type": "string",
            "example": "2026.08.11"
          },
          "last_updated": {
            "type": "string",
            "format": "date"
          },
          "license": {
            "type": "string",
            "example": "CC-BY-4.0"
          },
          "attribution_notice": {
            "type": "string"
          },
          "canonical_page": {
            "type": "string",
            "format": "uri"
          },
          "formula_count": {
            "type": "integer"
          },
          "formulas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Formula"
            }
          }
        }
      },
      "Formula": {
        "type": "object",
        "required": [
          "id",
          "name",
          "category",
          "equation",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "cun-bae"
          },
          "name": {
            "type": "string",
            "example": "CUN-BAE"
          },
          "category": {
            "type": "string",
            "example": "body-fat"
          },
          "equation": {
            "type": "string",
            "description": "Human-readable equation"
          },
          "inputs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "bmi",
              "age",
              "sex"
            ]
          },
          "source": {
            "type": "object",
            "properties": {
              "authors": {
                "type": "string"
              },
              "year": {
                "type": "integer"
              },
              "journal": {
                "type": "string"
              },
              "doi": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "sample": {
            "type": "object",
            "description": "Derivation sample",
            "additionalProperties": true
          },
          "error": {
            "type": "object",
            "description": "Reported error of the equation",
            "additionalProperties": true
          },
          "verification": {
            "type": "string",
            "description": "How the coefficients were checked against the source"
          },
          "independent_derivation": {
            "type": "boolean"
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "canonical_page": {
            "type": "string",
            "format": "uri"
          },
          "coefficients": {
            "type": "object",
            "description": "Coefficients keyed by term; values are numbers, or nested objects for sex-specific equations",
            "additionalProperties": true
          },
          "sex_coding": {
            "type": "string"
          },
          "units": {
            "type": "string",
            "example": "metric"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Plain-English explanation"
          }
        }
      },
      "CalcResponse": {
        "type": "object",
        "required": [
          "calculator",
          "inputs",
          "result",
          "formulas_used",
          "disclaimer",
          "attribution_notice"
        ],
        "properties": {
          "calculator": {
            "type": "string"
          },
          "inputs": {
            "type": "object",
            "additionalProperties": true,
            "description": "The parsed inputs that were used"
          },
          "result": {
            "type": "object",
            "additionalProperties": true,
            "description": "The range (low/high), unit, category or band, and each formula's value with its registry_id"
          },
          "formulas_used": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Registry ids of the formulas behind the result"
          },
          "formula_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "disclaimer": {
            "type": "string"
          },
          "attribution_notice": {
            "type": "string"
          },
          "registry_version": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Registry",
      "description": "Formula registry (CC BY 4.0)"
    },
    {
      "name": "Calculation",
      "description": "Honest-range calculations from your inputs"
    }
  ]
}
