{
  "openapi": "3.0.3",
  "info": {
    "title": "Currency Exchange Rate API",
    "version": "1.0.0",
    "description": "Real-time foreign exchange rates sourced from the European Central Bank (ECB) daily XML feed. No account or third-party API key required. Supports 30+ currencies, direct conversion, historical rate data for up to 90 days, and a full currency list with metadata. Rates update daily at ~16:00 CET.\n",
    "contact": {
      "name": "Currency Exchange Rate API Support",
      "email": "api@hiroapp.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/currency",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "tags": [
    {
      "name": "Rates",
      "description": "Current and historical exchange rates"
    },
    {
      "name": "Convert",
      "description": "Direct currency conversion"
    },
    {
      "name": "Currencies",
      "description": "Supported currencies list"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "RapidApiProxy": []
    }
  ],
  "paths": {
    "/api/v1/rates": {
      "get": {
        "operationId": "getRates",
        "summary": "Get current exchange rates",
        "description": "Returns all available exchange rates relative to a base currency. Default base is EUR (ECB reference rates). Rates are refreshed daily.\n",
        "tags": [
          "Rates"
        ],
        "parameters": [
          {
            "name": "base",
            "in": "query",
            "required": false,
            "description": "Base currency (ISO 4217 code)",
            "schema": {
              "type": "string",
              "default": "EUR"
            },
            "example": "USD"
          }
        ],
        "responses": {
          "200": {
            "description": "Exchange rates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RatesResult"
                },
                "example": {
                  "base": "EUR",
                  "date": "2026-05-28",
                  "rates": {
                    "USD": 1.0845,
                    "GBP": 0.8521,
                    "JPY": 163.42,
                    "CHF": 0.9734
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/convert": {
      "get": {
        "operationId": "convertCurrency",
        "summary": "Convert an amount between currencies",
        "description": "Convert a numeric amount from one currency to another using the latest ECB rates.\n",
        "tags": [
          "Convert"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Source currency (ISO 4217)",
            "schema": {
              "type": "string"
            },
            "example": "USD"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Target currency (ISO 4217)",
            "schema": {
              "type": "string"
            },
            "example": "EUR"
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "description": "Amount to convert",
            "schema": {
              "type": "number",
              "format": "float"
            },
            "example": 100
          }
        ],
        "responses": {
          "200": {
            "description": "Conversion result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConvertResult"
                },
                "example": {
                  "from": "USD",
                  "to": "EUR",
                  "amount": 100,
                  "result": 92.21,
                  "rate": 0.9221,
                  "date": "2026-05-28"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/currencies": {
      "get": {
        "operationId": "getCurrencies",
        "summary": "List all supported currencies",
        "description": "Returns all currencies supported by the ECB feed with their ISO codes.",
        "tags": [
          "Currencies"
        ],
        "responses": {
          "200": {
            "description": "Supported currencies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrenciesResult"
                },
                "example": {
                  "currencies": [
                    "USD",
                    "EUR",
                    "GBP",
                    "JPY"
                  ],
                  "count": 32
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/history": {
      "get": {
        "operationId": "getHistoricalRates",
        "summary": "Historical exchange rates for a currency",
        "description": "Returns daily exchange rates (vs EUR base) for a given currency over the last N days. Maximum lookback is 90 days.\n",
        "tags": [
          "Rates"
        ],
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "description": "Currency code (ISO 4217)",
            "schema": {
              "type": "string"
            },
            "example": "USD"
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "Number of days of history (1–90)",
            "schema": {
              "type": "integer",
              "default": 30,
              "minimum": 1,
              "maximum": 90
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Historical rates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryResult"
                },
                "example": {
                  "currency": "USD",
                  "days": 7,
                  "data": [
                    {
                      "date": "2026-05-22",
                      "rate": 1.0812
                    },
                    {
                      "date": "2026-05-23",
                      "rate": 1.0834
                    },
                    {
                      "date": "2026-05-28",
                      "rate": 1.0845
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "RapidApiProxy": {
        "type": "apiKey",
        "in": "header",
        "name": "x-rapidapi-proxy-secret"
      }
    },
    "schemas": {
      "RatesResult": {
        "type": "object",
        "properties": {
          "base": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "rates": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "format": "float"
            }
          }
        }
      },
      "ConvertResult": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "amount": {
            "type": "number",
            "format": "float"
          },
          "result": {
            "type": "number",
            "format": "float"
          },
          "rate": {
            "type": "number",
            "format": "float"
          },
          "date": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "CurrenciesResult": {
        "type": "object",
        "properties": {
          "currencies": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "HistoryEntry": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "rate": {
            "type": "number",
            "format": "float"
          }
        }
      },
      "HistoryResult": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "days": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEntry"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request — missing or invalid parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Query param 'from' required"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "API key required"
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Currency not found or rate unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Unknown currency: XYZ"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (100 requests per minute)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded"
            }
          }
        }
      }
    }
  }
}