{
  "openapi": "3.1.1",
  "info": {
    "title": "Inflation Time Machine API",
    "version": "1.0.0",
    "summary": "What was money from one year worth in another? CPI-based, 20 countries, World Bank data.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://inflationtimemachine.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "What was money from one year worth in another? CPI-based, 20 countries, World Bank data.",
        "description": "Convert an amount between years with the consumer price index (2010 = 100) published by the World Bank. Shows the equivalent value, cumulative inflation, average annual inflation and lost purchasing power, with a year-by-year table.\n\nMethodology:\n- Data: World Bank WDI indicator FP.CPI.TOTL, consumer price index (2010 = 100), annual averages, snapshot stored with retrieval date.\n- Equivalent value = amount × CPI(to year) ÷ CPI(from year).\n- Cumulative inflation = (CPI(later) ÷ CPI(earlier) − 1) × 100.\n- Average annual inflation (CAGR) = ((CPI(later) ÷ CPI(earlier))^(1 ÷ years) − 1) × 100.\n- Purchasing power loss = (1 − CPI(earlier) ÷ CPI(later)) × 100: how much less the same nominal amount buys in the later year.\n- Because CPI values are annual averages, results compare average price levels of whole years, not specific dates.",
        "tags": [
          "money"
        ],
        "x-mcp-tool": "inflation_time_machine",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InflationTimeMachineInput"
              },
              "examples": {
                "example1": {
                  "summary": "100 EUR in Germany, 2000 → 2024",
                  "value": {
                    "amount": 100,
                    "currency": "EUR",
                    "fromYear": 2000,
                    "toYear": 2024,
                    "country": "DE"
                  }
                },
                "example2": {
                  "summary": "1,000 USD in the US, 1980 → 2024",
                  "value": {
                    "amount": 1000,
                    "currency": "USD",
                    "fromYear": 1980,
                    "toYear": 2024,
                    "country": "US"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InflationTimeMachineResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "InflationTimeMachineInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "amount": {
            "title": "Amount",
            "type": "number",
            "minimum": 0,
            "default": 100
          },
          "currency": {
            "title": "Currency label",
            "description": "Label only. Use the currency of the chosen country; no conversion is done.",
            "type": "string",
            "maxLength": 8,
            "default": "EUR"
          },
          "fromYear": {
            "title": "From year",
            "type": "integer",
            "minimum": 1960,
            "maximum": 2100,
            "default": 2000
          },
          "toYear": {
            "title": "To year",
            "type": "integer",
            "minimum": 1960,
            "maximum": 2100,
            "default": 2024
          },
          "country": {
            "title": "Country",
            "type": "string",
            "enum": [
              "US",
              "GB",
              "DE",
              "FR",
              "IT",
              "ES",
              "NL",
              "AT",
              "CH",
              "SE",
              "PL",
              "CA",
              "AU",
              "JP",
              "IN",
              "BR",
              "MX",
              "ZA",
              "TR",
              "CN"
            ],
            "default": "DE"
          }
        },
        "required": [
          "amount",
          "fromYear",
          "toYear"
        ]
      },
      "InflationTimeMachineResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "country",
              "countryName",
              "amount",
              "fromYear",
              "toYear",
              "cpiFrom",
              "cpiTo",
              "equivalentValue",
              "cumulativeInflationPercent",
              "averageAnnualInflationPercent",
              "purchasingPowerLossPercent",
              "years",
              "dataLastUpdated"
            ],
            "properties": {
              "country": {
                "type": "string"
              },
              "countryName": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "fromYear": {
                "type": "integer"
              },
              "toYear": {
                "type": "integer"
              },
              "cpiFrom": {
                "type": "number",
                "description": "CPI (2010 = 100) in the from-year."
              },
              "cpiTo": {
                "type": "number",
                "description": "CPI (2010 = 100) in the to-year."
              },
              "equivalentValue": {
                "type": "number",
                "description": "amount × CPI(to) ÷ CPI(from)."
              },
              "cumulativeInflationPercent": {
                "type": "number",
                "description": "(CPI(to) ÷ CPI(from) − 1) × 100."
              },
              "averageAnnualInflationPercent": {
                "type": "number",
                "description": "Compound annual rate between the earlier and later year."
              },
              "purchasingPowerLossPercent": {
                "type": "number",
                "description": "Share of purchasing power lost from the earlier to the later year (negative = gain)."
              },
              "dataLastUpdated": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "years": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "year",
                    "cpi",
                    "value",
                    "inflationPercent"
                  ],
                  "properties": {
                    "year": {
                      "type": "integer"
                    },
                    "cpi": {
                      "type": "number"
                    },
                    "value": {
                      "type": "number",
                      "description": "Amount expressed in this year's prices."
                    },
                    "inflationPercent": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Change of CPI vs. the previous listed year."
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}