{
  "openapi": "3.1.0",
  "info": {
    "title": "MortgageCalculator.me Calculator API",
    "version": "1.0.0",
    "summary": "Free mortgage calculator API: payments, refinance, APR, rent vs. buy and more.",
    "description": "Runs any of MortgageCalculator.me\u0027s 16 mortgage calculators and returns the results as JSON. Free, no API key, CORS open to any website, 120 requests per minute per IP. Inputs you leave out use their defaults; values may include $, commas and %.",
    "termsOfService": "https://mortgagecalculator.me/Terms-Of-Service",
    "contact": {
      "name": "MortgageCalculator.me",
      "url": "https://mortgagecalculator.me/Contact-Us"
    }
  },
  "externalDocs": {
    "description": "Developer guide",
    "url": "https://mortgagecalculator.me/developers"
  },
  "servers": [
    {
      "url": "https://mortgagecalculator.me"
    }
  ],
  "tags": [
    {
      "name": "Calculators",
      "description": "Mortgage and refinance calculators."
    }
  ],
  "paths": {
    "/api/v1/calculators": {
      "get": {
        "operationId": "listCalculators",
        "summary": "List all calculators",
        "tags": [
          "Calculators"
        ],
        "responses": {
          "200": {
            "description": "Every calculator.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CalculatorSummary"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown calculator.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from one IP. Wait a minute and try again.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calculators/{slug}": {
      "get": {
        "operationId": "getCalculator",
        "summary": "Describe one calculator and its inputs",
        "tags": [
          "Calculators"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Which calculator. GET /api/v1/calculators lists them.",
            "schema": {
              "type": "string",
              "enum": [
                "mortgage-payment-calculator",
                "mortgage-refinance-calculator",
                "additional-payment-calculator",
                "apr-calculator",
                "which-loan-is-better-calculator",
                "mortgage-points-calculator",
                "rent-vs-buy-calculator",
                "how-much-income-do-i-need-to-qualify",
                "standard-vs-biweekly-calculator",
                "interest-only-calculator",
                "interest-only-with-additional-payment-calculator",
                "mortgage-length-calculator",
                "mortgage-principal-calculator",
                "tax-benefits-calculator",
                "cash-out-refinance-calculator",
                "should-i-use-heloc"
              ]
            },
            "example": "mortgage-payment-calculator"
          }
        ],
        "responses": {
          "200": {
            "description": "The calculator\u0027s inputs, defaults and limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorDefinition"
                }
              }
            }
          },
          "404": {
            "description": "Unknown calculator.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from one IP. Wait a minute and try again.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calculators/{slug}/calculate": {
      "get": {
        "operationId": "calculate",
        "summary": "Run a calculator with inputs in the query string",
        "description": "Pass each input as a query parameter named by its key, for example \u0060?Balance=300000\u0026Rate=6.5\u0026Term=30\u0060. GET /api/v1/calculators/{slug} lists the keys.",
        "tags": [
          "Calculators"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Which calculator. GET /api/v1/calculators lists them.",
            "schema": {
              "type": "string",
              "enum": [
                "mortgage-payment-calculator",
                "mortgage-refinance-calculator",
                "additional-payment-calculator",
                "apr-calculator",
                "which-loan-is-better-calculator",
                "mortgage-points-calculator",
                "rent-vs-buy-calculator",
                "how-much-income-do-i-need-to-qualify",
                "standard-vs-biweekly-calculator",
                "interest-only-calculator",
                "interest-only-with-additional-payment-calculator",
                "mortgage-length-calculator",
                "mortgage-principal-calculator",
                "tax-benefits-calculator",
                "cash-out-refinance-calculator",
                "should-i-use-heloc"
              ]
            },
            "example": "mortgage-payment-calculator"
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to \u0060schedule\u0060 to add a year-by-year amortization schedule.",
            "schema": {
              "type": "string",
              "enum": [
                "schedule"
              ]
            }
          },
          {
            "name": "inputs",
            "in": "query",
            "required": false,
            "style": "form",
            "explode": true,
            "description": "Calculator inputs as key=value pairs.",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": {
              "Balance": "300000",
              "Rate": "6.5",
              "Term": "30"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResult"
                }
              }
            }
          },
          "400": {
            "description": "One or more inputs are invalid; \u0060errors\u0060 says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResult"
                }
              }
            }
          },
          "404": {
            "description": "Unknown calculator.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from one IP. Wait a minute and try again.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "calculatePost",
        "summary": "Run a calculator with inputs as a JSON object",
        "tags": [
          "Calculators"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Which calculator. GET /api/v1/calculators lists them.",
            "schema": {
              "type": "string",
              "enum": [
                "mortgage-payment-calculator",
                "mortgage-refinance-calculator",
                "additional-payment-calculator",
                "apr-calculator",
                "which-loan-is-better-calculator",
                "mortgage-points-calculator",
                "rent-vs-buy-calculator",
                "how-much-income-do-i-need-to-qualify",
                "standard-vs-biweekly-calculator",
                "interest-only-calculator",
                "interest-only-with-additional-payment-calculator",
                "mortgage-length-calculator",
                "mortgage-principal-calculator",
                "tax-benefits-calculator",
                "cash-out-refinance-calculator",
                "should-i-use-heloc"
              ]
            },
            "example": "mortgage-payment-calculator"
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Set to \u0060schedule\u0060 to add a year-by-year amortization schedule.",
            "schema": {
              "type": "string",
              "enum": [
                "schedule"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "example": {
                  "Balance": 300000,
                  "Rate": 6.5,
                  "Term": "30"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The results.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResult"
                }
              }
            }
          },
          "400": {
            "description": "One or more inputs are invalid; \u0060errors\u0060 says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResult"
                }
              }
            }
          },
          "413": {
            "description": "The body is over 16 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown calculator.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from one IP. Wait a minute and try again.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "CalculatorSummary": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "example": "mortgage-payment-calculator"
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The calculator\u0027s page on MortgageCalculator.me."
          },
          "api": {
            "type": "string",
            "format": "uri",
            "description": "This calculator\u0027s API definition."
          }
        }
      },
      "Option": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "CalculatorDefinition": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "The input\u0027s name in a calculate request."
                },
                "label": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "money",
                    "percent",
                    "years",
                    "months",
                    "number",
                    "select",
                    "toggle",
                    "month"
                  ],
                  "description": "month takes a calendar month such as 2026-11."
                },
                "default": {
                  "type": "string"
                },
                "help": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "placeholder": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "For optional inputs: what is used when the value is left out."
                },
                "group": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "min": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "max": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "options": {
                  "type": [
                    "array",
                    "null"
                  ],
                  "items": {
                    "$ref": "#/components/schemas/Option"
                  }
                },
                "unit": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "description": "A companion input that sets this one\u0027s units, for example percent or dollars.",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "default": {
                      "type": "string"
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Option"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "CalculationResult": {
        "type": "object",
        "properties": {
          "calculator": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Opens these results on MortgageCalculator.me."
          },
          "headline": {
            "type": "string",
            "description": "A one-sentence answer, for calculators that have one."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "values": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            },
            "description": "Key results, unformatted."
          },
          "sections": {
            "type": "array",
            "description": "The result tables shown on the calculator page, already formatted.",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "values": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "emphasis": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "charts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "x": {
                  "type": "string"
                },
                "y": {
                  "type": "string"
                },
                "bar": {
                  "type": "boolean"
                },
                "donut": {
                  "type": "boolean",
                  "description": "A donut chart: one series split into the labels."
                },
                "labels": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "series": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "points": {
                        "type": "array",
                        "items": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "schedules": {
            "type": [
              "array",
              "null"
            ],
            "description": "Present with include=schedule.",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string"
                },
                "periodsPerYear": {
                  "type": "integer"
                },
                "payments": {
                  "type": "integer"
                },
                "totalInterest": {
                  "type": "number"
                },
                "years": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "year": {
                        "type": "integer"
                      },
                      "paid": {
                        "type": "number"
                      },
                      "interest": {
                        "type": "number"
                      },
                      "principal": {
                        "type": "number"
                      },
                      "balance": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}