{
  "openapi": "3.1.0",
  "info": {
    "title": "AllRatesToday Currency Exchange API",
    "description": "Real-time and historical currency exchange rates API powered by AllRatesToday.\n\n## Overview\nAllRatesToday provides accurate mid-market exchange rates for 160+ currencies sourced from Reuters (Refinitiv) and interbank market feeds. Our API is designed for:\n- Currency converters and calculators\n- Financial applications\n- E-commerce platforms\n- AI chatbots and assistants\n\n## Authentication\nMost endpoints require an API key via the `Authorization: Bearer <api_key>` header. The `/api/v1/symbols` endpoint is public and does not require authentication.\n\n## Monthly Quotas\n| Plan | Monthly Limit |\n|------|---------------|\n| Free | 300 requests/month |\n| Small | 5,000 requests/month |\n| Medium | 10,000 requests/month |\n| Large | 100,000 requests/month |\n\n## Getting an API Key\n1. Register at [allratestoday.com/register](https://allratestoday.com/register)\n2. Verify your email\n3. Find your API key in your dashboard\n",
    "version": "1.0.0",
    "contact": {
      "name": "AllRatesToday Support",
      "url": "https://allratestoday.com",
      "email": "support@allratestoday.com"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "servers": [
    {
      "url": "https://allratestoday.com/api",
      "description": "Production server"
    }
  ],
  "tags": [
    {
      "name": "Exchange Rates",
      "description": "Get current and historical exchange rates"
    },
    {
      "name": "News",
      "description": "Financial news and market updates"
    }
  ],
  "paths": {
    "/rate": {
      "get": {
        "tags": [
          "Exchange Rates"
        ],
        "summary": "Get current exchange rate",
        "description": "Returns the current mid-market exchange rate between two currencies. This is a simple rate lookup endpoint.\n",
        "operationId": "getCurrentRate",
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "required": true,
            "description": "Source currency code (ISO 4217)",
            "schema": {
              "type": "string",
              "example": "USD",
              "minLength": 3,
              "maxLength": 3
            }
          },
          {
            "name": "target",
            "in": "query",
            "required": true,
            "description": "Target currency code (ISO 4217)",
            "schema": {
              "type": "string",
              "example": "EUR",
              "minLength": 3,
              "maxLength": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with exchange rate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateResponse"
                },
                "example": {
                  "rate": 0.92145,
                  "source": "wise"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "Missing required parameters"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/historical-rates": {
      "get": {
        "tags": [
          "Exchange Rates"
        ],
        "summary": "Get historical exchange rates",
        "description": "Returns historical exchange rate data for a currency pair over a specified time period.\nData points vary by period:\n- 1d: Hourly data points\n- 7d: Daily data points\n- 30d: Daily data points\n- 1y: Weekly data points\n",
        "operationId": "getHistoricalRates",
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "required": true,
            "description": "Source currency code (ISO 4217)",
            "schema": {
              "type": "string",
              "example": "USD"
            }
          },
          {
            "name": "target",
            "in": "query",
            "required": true,
            "description": "Target currency code (ISO 4217)",
            "schema": {
              "type": "string",
              "example": "INR"
            }
          },
          {
            "name": "period",
            "in": "query",
            "required": false,
            "description": "Time period for historical data",
            "schema": {
              "type": "string",
              "enum": [
                "1d",
                "7d",
                "30d",
                "1y"
              ],
              "default": "7d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with historical rates",
            "headers": {
              "Cache-Control": {
                "description": "Cache duration",
                "schema": {
                  "type": "string",
                  "example": "public, max-age=3600"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoricalRatesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/rates": {
      "get": {
        "tags": [
          "Exchange Rates"
        ],
        "summary": "Authenticated exchange rate API",
        "description": "Get exchange rates with higher rate limits using API key authentication.\nSupports fetching multiple currency pairs and historical data.\n",
        "operationId": "getAuthenticatedRates",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "SessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Source currency code (or use 'from')",
            "schema": {
              "type": "string",
              "example": "USD"
            }
          },
          {
            "name": "target",
            "in": "query",
            "required": false,
            "description": "Target currency code. Supports comma-separated values for multiple targets (e.g. EUR,GBP,JPY)",
            "schema": {
              "type": "string",
              "example": "EUR"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Alternate source currency parameter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Alternate target currency parameter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "time",
            "in": "query",
            "required": false,
            "description": "Historical timestamp (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "group",
            "in": "query",
            "required": false,
            "description": "Group rates by time period",
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with rates",
            "headers": {
              "X-RateLimit-Remaining": {
                "description": "Remaining requests",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Total requests allowed",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Reset timestamp",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AuthenticatedRateItem"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Authentication required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/symbols": {
      "get": {
        "tags": [
          "Exchange Rates"
        ],
        "summary": "List all supported currencies",
        "description": "Returns all supported currency codes, names, and symbols. No authentication required. Response is cached for 24 hours.",
        "operationId": "getSymbols",
        "responses": {
          "200": {
            "description": "List of supported currencies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currencies": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": { "type": "string", "example": "USD" },
                          "name": { "type": "string", "example": "US Dollar" },
                          "symbol": { "type": "string", "example": "$" }
                        }
                      }
                    },
                    "count": { "type": "integer", "example": 48 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/news": {
      "get": {
        "tags": [
          "News"
        ],
        "summary": "Get financial news",
        "description": "Returns the latest financial and currency market news from various sources.\nNews is aggregated from Bloomberg, Investing.com, and Google News.\n",
        "operationId": "getNews",
        "responses": {
          "200": {
            "description": "Successful response with news articles",
            "headers": {
              "Cache-Control": {
                "description": "Cache duration",
                "schema": {
                  "type": "string",
                  "example": "public, max-age=1800"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NewsResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key authentication. Get your API key from your AllRatesToday dashboard.\n\nExample: `Authorization: Bearer art_live_xxxxx`\n"
      },
      "SessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "art_session",
        "description": "Session cookie (for logged-in users)"
      }
    },
    "schemas": {
      "RateResponse": {
        "type": "object",
        "required": [
          "rate",
          "source"
        ],
        "properties": {
          "rate": {
            "type": "number",
            "format": "double",
            "description": "Current exchange rate",
            "example": 0.92145
          },
          "source": {
            "type": "string",
            "description": "Data source provider",
            "example": "wise"
          }
        }
      },
      "HistoricalRatesResponse": {
        "type": "object",
        "required": [
          "source",
          "target",
          "data",
          "period"
        ],
        "properties": {
          "source": {
            "type": "string",
            "description": "Source currency code",
            "example": "USD"
          },
          "target": {
            "type": "string",
            "description": "Target currency code",
            "example": "INR"
          },
          "data": {
            "type": "array",
            "description": "Historical rate data points",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date-time",
                  "description": "Data point timestamp"
                },
                "rate": {
                  "type": "number",
                  "format": "double",
                  "description": "Exchange rate at this time"
                },
                "timestamp": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Unix timestamp in milliseconds"
                }
              }
            }
          },
          "source_api": {
            "type": "string",
            "description": "Data source provider",
            "example": "wise"
          },
          "period": {
            "type": "string",
            "description": "Requested time period",
            "enum": [
              "1d",
              "7d",
              "30d",
              "1y"
            ]
          }
        }
      },
      "AuthenticatedRateItem": {
        "type": "object",
        "properties": {
          "rate": {
            "type": "number",
            "format": "double",
            "description": "Exchange rate"
          },
          "source": {
            "type": "string",
            "description": "Source currency code"
          },
          "target": {
            "type": "string",
            "description": "Target currency code"
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "Rate timestamp"
          }
        }
      },
      "NewsResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "success"
          },
          "totalResults": {
            "type": "integer",
            "description": "Total number of articles",
            "example": 15
          },
          "articles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NewsArticle"
            }
          },
          "sidebarNews": {
            "type": "array",
            "description": "Additional news for sidebar display",
            "items": {
              "$ref": "#/components/schemas/NewsArticle"
            }
          }
        }
      },
      "NewsArticle": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "description": "Article headline"
          },
          "description": {
            "type": "string",
            "description": "Article summary"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Link to full article"
          },
          "image": {
            "type": "string",
            "format": "uri",
            "description": "Article thumbnail image"
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Publication date"
          },
          "source": {
            "type": "string",
            "description": "News source name"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message"
          }
        }
      },
      "RateLimitError": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "Rate limit exceeded"
          },
          "retryAfter": {
            "type": "integer",
            "description": "Seconds until rate limit resets"
          }
        }
      },
      "Currency": {
        "type": "object",
        "description": "Currency information",
        "properties": {
          "code": {
            "type": "string",
            "description": "ISO 4217 currency code",
            "example": "USD"
          },
          "name": {
            "type": "string",
            "description": "Currency name",
            "example": "US Dollar"
          },
          "symbol": {
            "type": "string",
            "description": "Currency symbol",
            "example": "$"
          },
          "flag": {
            "type": "string",
            "description": "Country flag code",
            "example": "us"
          }
        }
      }
    }
  }
}
