{
  "openapi": "3.1.1",
  "info": {
    "title": "Historical FX Chart API",
    "version": "1.0.0",
    "summary": "Chart exchange rates over time from ECB data: min, max, average, change, volatility and CSV export.",
    "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://historicalfxchart.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Chart exchange rates over time from ECB data: min, max, average, change, volatility and CSV export.",
        "description": "Pick a base currency, one or more quote currencies and a date range (back to 1999). The tool loads the ECB’s daily euro reference rates, builds the cross rates, draws a line chart (indexed to 100 to compare several pairs) and reports start, end, minimum, maximum, average, change and annualised volatility, with a CSV download.\n\nMethodology:\n- Daily reference rates (units per euro) are loaded from the ECB Data Portal SDMX API as CSV (series D.<currency>.EUR.SP00.A, only the requested currencies and dates) and cached; ranges ending more than a week ago are cached permanently, recent ranges per day.\n- Cross rate base/quote on each publication day = rate(quote) ÷ rate(base); days where either leg is missing are skipped. EUR legs are 1.\n- Statistics: first and last observation, minimum and maximum with dates, arithmetic mean, change = last ÷ first − 1, annualised volatility = standard deviation of daily log returns × √252.\n- Indexed view: every pair divided by its first value × 100, so pairs with very different levels (e.g. JPY and GBP) can be compared.\n\nReference rates for information; they are not the rates at which you could have traded.",
        "tags": [
          "money"
        ],
        "x-mcp-tool": "historical_fx_chart",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HistoricalFxChartInput"
              },
              "examples": {
                "example1": {
                  "summary": "EUR/USD and EUR/GBP over 2024 (indexed)",
                  "value": {
                    "base": "EUR",
                    "quotes": "USD, GBP",
                    "start": "2024-01-01",
                    "end": "2024-12-31"
                  }
                },
                "example2": {
                  "summary": "USD/JPY in 2023",
                  "value": {
                    "base": "USD",
                    "quotes": "JPY",
                    "start": "2023-01-01",
                    "end": "2023-12-31",
                    "png": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoricalFxChartResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "HistoricalFxChartInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "base": {
            "title": "Base currency",
            "description": "The rate shows how many units of the quote currency one unit of the base buys.",
            "type": "string",
            "maxLength": 3,
            "default": "EUR"
          },
          "quotes": {
            "title": "Quote currencies",
            "description": "Up to 6 ISO codes, comma-separated.",
            "type": "string",
            "maxLength": 100,
            "default": "USD, GBP"
          },
          "start": {
            "title": "From",
            "description": "Default: one year before the end date. Earliest 1999-01-04.",
            "type": "string",
            "format": "date"
          },
          "end": {
            "title": "To",
            "description": "Default: today.",
            "type": "string",
            "format": "date"
          },
          "normalise": {
            "title": "Index to 100 at the start",
            "type": "string",
            "enum": [
              "auto",
              "yes",
              "no"
            ],
            "default": "auto"
          },
          "png": {
            "title": "Also create a PNG image",
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "base",
          "quotes"
        ]
      },
      "HistoricalFxChartResult": {
        "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": [
              "base",
              "quotes",
              "start",
              "end",
              "normalised",
              "pairs",
              "svg",
              "png",
              "dataUrl"
            ],
            "properties": {
              "base": {
                "type": "string"
              },
              "quotes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "start": {
                "type": "string"
              },
              "end": {
                "type": "string"
              },
              "normalised": {
                "type": "boolean"
              },
              "pairs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "pair",
                    "base",
                    "quote",
                    "observations",
                    "start",
                    "end",
                    "min",
                    "max",
                    "average",
                    "changePercent",
                    "annualisedVolatilityPercent"
                  ],
                  "properties": {
                    "pair": {
                      "type": "string"
                    },
                    "base": {
                      "type": "string"
                    },
                    "quote": {
                      "type": "string"
                    },
                    "observations": {
                      "type": "integer"
                    },
                    "start": {
                      "type": "object"
                    },
                    "end": {
                      "type": "object"
                    },
                    "min": {
                      "type": "object"
                    },
                    "max": {
                      "type": "object"
                    },
                    "average": {
                      "type": "number"
                    },
                    "changePercent": {
                      "type": "number"
                    },
                    "annualisedVolatilityPercent": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  }
                }
              },
              "svg": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "png": {
                "anyOf": [
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "dataUrl": {
                "type": "string",
                "description": "ECB Data Portal request used."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}