{
  "openapi": "3.0.3",
  "info": {
    "title": "CC currency converter API",
    "version": "1.0.0",
    "description": "Mid-market exchange rates for fiat, crypto and stablecoins, and the list of services that can move money between two currencies. Free, no key, CORS enabled. Rates are indicative, median of several public sources."
  },
  "servers": [{ "url": "https://currency-backend.currency-backend.workers.dev" }],
  "paths": {
    "/api/rate": {
      "get": {
        "summary": "Exchange rate for a currency pair",
        "operationId": "getRate",
        "parameters": [
          { "name": "base", "in": "query", "required": true, "schema": { "type": "string", "example": "USD" }, "description": "Currency you have (ISO 4217 or crypto ticker). Case-insensitive." },
          { "name": "quote", "in": "query", "required": true, "schema": { "type": "string", "example": "EUR" }, "description": "Currency you want." },
          { "name": "amount", "in": "query", "required": false, "schema": { "type": "number", "example": 100 }, "description": "Optional amount in base currency to convert." },
          { "name": "lang", "in": "query", "required": false, "schema": { "type": "string", "example": "en" }, "description": "Language for currency names (en, es, pt, fr, de, it, ru, tr, ar, hi, id, zh, ja, ko)." }
        ],
        "responses": {
          "200": {
            "description": "Rate found",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "base": { "type": "string" }, "quote": { "type": "string" },
                "rate": { "type": "number", "description": "Units of quote per 1 base" },
                "inverse": { "type": "number" },
                "amount": { "type": "number", "nullable": true }, "converted": { "type": "number", "nullable": true },
                "updatedAt": { "type": "string", "format": "date-time" },
                "sources": { "type": "array", "items": { "type": "string" } },
                "names": { "type": "object", "properties": { "base": { "type": "string" }, "quote": { "type": "string" } } },
                "kinds": { "type": "object", "properties": { "base": { "type": "string" }, "quote": { "type": "string" } } },
                "decimals": { "type": "object", "properties": { "base": { "type": "integer" }, "quote": { "type": "integer" } } },
                "providers": { "type": "array", "description": "Services that accept base and pay out quote", "items": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "website": { "type": "string" } } } },
                "converter": { "type": "string", "format": "uri", "description": "Link to the interactive converter for this pair" }
              }
            } } }
          },
          "400": { "description": "Unknown currency code" },
          "503": { "description": "Rate temporarily unavailable" }
        }
      }
    },
    "/api/currencies": {
      "get": {
        "summary": "Supported currencies",
        "operationId": "listCurrencies",
        "parameters": [ { "name": "lang", "in": "query", "required": false, "schema": { "type": "string", "example": "en" } } ],
        "responses": { "200": { "description": "Currency list with codes, localized names, kind and icons" } }
      }
    }
  }
}
