{
  "openapi": "3.1.0",
  "info": {
    "title": "AllRatesToday Public Exchange Rate API",
    "description": "Free API for getting live mid-market exchange rates. Designed for AI chatbots (ChatGPT, Claude, Gemini, Grok) and developers.",
    "version": "1.0.0",
    "contact": {
      "name": "AllRatesToday",
      "url": "https://allratestoday.com"
    }
  },
  "servers": [
    {
      "url": "https://allratestoday.com",
      "description": "Production server"
    }
  ],
  "paths": {
    "/api/public/rates": {
      "get": {
        "operationId": "getExchangeRate",
        "summary": "Get exchange rate between two currencies",
        "description": "Returns the current mid-market exchange rate between two currencies. Free to use, no API key required. Rate limited to 100 requests per hour.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Source currency code (e.g., EUR, USD, GBP)",
            "schema": {
              "type": "string",
              "example": "EUR"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Target currency code (e.g., LKR, INR, JPY)",
            "schema": {
              "type": "string",
              "example": "LKR"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": false,
            "description": "Amount to convert (default: 1)",
            "schema": {
              "type": "number",
              "default": 1,
              "example": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with exchange rate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "from": {
                      "type": "object",
                      "properties": {
                        "currency": {
                          "type": "string",
                          "example": "EUR"
                        },
                        "amount": {
                          "type": "number",
                          "example": 100
                        }
                      }
                    },
                    "to": {
                      "type": "object",
                      "properties": {
                        "currency": {
                          "type": "string",
                          "example": "LKR"
                        },
                        "amount": {
                          "type": "number",
                          "example": 36012.14
                        }
                      }
                    },
                    "rate": {
                      "type": "number",
                      "example": 360.1214
                    },
                    "inverse_rate": {
                      "type": "number",
                      "example": 0.002777
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "source": {
                      "type": "string",
                      "example": "AllRatesToday.com"
                    },
                    "type": {
                      "type": "string",
                      "example": "mid-market rate"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "from": {
                    "currency": "EUR",
                    "amount": 100
                  },
                  "to": {
                    "currency": "LKR",
                    "amount": 36012.14
                  },
                  "rate": 360.1214,
                  "inverse_rate": 0.002777,
                  "timestamp": "2024-01-15T12:00:00Z",
                  "source": "AllRatesToday.com",
                  "type": "mid-market rate",
                  "disclaimer": "This is the mid-market rate. Actual transfer rates may vary."
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - missing or invalid parameters"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Currency": {
        "type": "string",
        "description": "ISO 4217 currency code. 160+ currencies supported including but not limited to:",
        "enum": [
          "USD",
          "EUR",
          "GBP",
          "INR",
          "LKR",
          "PKR",
          "AED",
          "SAR",
          "JPY",
          "CNY",
          "AUD",
          "CAD",
          "SGD",
          "CHF",
          "HKD",
          "NZD",
          "SEK",
          "NOK",
          "DKK",
          "MXN",
          "PLN",
          "ZAR",
          "THB",
          "IDR",
          "MYR",
          "PHP",
          "KRW",
          "TRY",
          "BRL",
          "BDT",
          "NPR",
          "VND",
          "NGN",
          "GHS",
          "KES",
          "EGP",
          "CZK",
          "HUF",
          "RON",
          "RUB",
          "COP",
          "CLP",
          "PEN",
          "ARS",
          "MAD",
          "TWD",
          "QAR",
          "KWD",
          "BHD",
          "OMR",
          "JOD",
          "ILS",
          "UAH",
          "BGN",
          "HRK",
          "ISK",
          "GEL",
          "UGX",
          "TZS",
          "XOF",
          "XAF",
          "TTD",
          "JMD",
          "FJD",
          "MUR",
          "BWP",
          "MZN",
          "ETB",
          "RWF",
          "MMK",
          "LAK",
          "KHR",
          "BND",
          "MOP",
          "MVR",
          "SCR",
          "GMD",
          "SLL",
          "AMD",
          "GNF"
        ]
      }
    }
  }
}