{
  "openapi": "3.1.0",
  "info": {
    "title": "MoneroSwapper Public API",
    "description": "REST API for the MoneroSwapper anonymous, no-KYC cryptocurrency exchange. Lists supported coins, retrieves real-time exchange rates, creates and tracks swap transactions across 1900+ cryptocurrencies including Monero (XMR), Bitcoin (BTC), Ethereum (ETH), and USDT.",
    "version": "2.0.0",
    "termsOfService": "https://moneroswapper.com/terms.php",
    "contact": {
      "name": "MoneroSwapper Support",
      "url": "https://moneroswapper.com/support.php"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://moneroswapper.com/terms.php"
    }
  },
  "servers": [
    {"url": "https://moneroswapper.com/api/v2", "description": "Production"}
  ],
  "externalDocs": {
    "description": "Full API documentation",
    "url": "https://moneroswapper.com/api-docs.php"
  },
  "tags": [
    {"name": "Currencies", "description": "List supported cryptocurrencies"},
    {"name": "Rates",      "description": "Get real-time exchange rates"},
    {"name": "Transactions","description": "Create and track swap transactions"}
  ],
  "paths": {
    "/currencies": {
      "get": {
        "tags": ["Currencies"],
        "summary": "List supported cryptocurrencies",
        "description": "Returns the paginated list of cryptocurrencies that can be swapped on MoneroSwapper. Includes ticker symbol, full name, and supported network/contract metadata.",
        "operationId": "listCurrencies",
        "parameters": [
          {"name": "page",   "in": "query", "schema": {"type": "integer", "default": 1, "minimum": 1}},
          {"name": "size",   "in": "query", "schema": {"type": "integer", "default": 50, "minimum": 1, "maximum": 100}},
          {"name": "search", "in": "query", "schema": {"type": "string"}, "description": "Filter by ticker or name (e.g. 'monero', 'btc')"}
        ],
        "responses": {
          "200": {
            "description": "Paginated currency list",
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/CurrencyListResponse"}
              }
            }
          },
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/rate": {
      "get": {
        "tags": ["Rates"],
        "summary": "Get exchange rate estimate",
        "description": "Returns the estimated amount the user will receive when swapping a given amount of one cryptocurrency for another. Supports both fixed and floating rate types.",
        "operationId": "getRate",
        "parameters": [
          {"name": "coinFrom", "in": "query", "required": true, "schema": {"type": "string", "example": "BTC"}},
          {"name": "coinTo",   "in": "query", "required": true, "schema": {"type": "string", "example": "XMR"}},
          {"name": "amount",   "in": "query", "required": true, "schema": {"type": "number", "format": "double", "example": 0.1}},
          {"name": "rateType", "in": "query", "schema": {"type": "string", "enum": ["fixed", "float"], "default": "float"}}
        ],
        "responses": {
          "200": {
            "description": "Rate estimate",
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/RateResponse"}
              }
            }
          },
          "400": {"$ref": "#/components/responses/BadRequest"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/transactions": {
      "post": {
        "tags": ["Transactions"],
        "summary": "Create a new swap transaction",
        "description": "Creates a new swap order. Returns a deposit address; once funds arrive at that address with the required network confirmations, the destination cryptocurrency is sent to the user-supplied wallet address.",
        "operationId": "createTransaction",
        "security": [{"ApiKey": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {"$ref": "#/components/schemas/CreateTransactionRequest"}
            }
          }
        },
        "responses": {
          "201": {
            "description": "Transaction created",
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/Transaction"}
              }
            }
          },
          "400": {"$ref": "#/components/responses/BadRequest"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      },
      "get": {
        "tags": ["Transactions"],
        "summary": "List transactions",
        "description": "Lists transactions associated with the authenticated API key.",
        "operationId": "listTransactions",
        "security": [{"ApiKey": []}],
        "parameters": [
          {"name": "page", "in": "query", "schema": {"type": "integer", "default": 1, "minimum": 1}},
          {"name": "size", "in": "query", "schema": {"type": "integer", "default": 20, "minimum": 1, "maximum": 100}}
        ],
        "responses": {
          "200": {
            "description": "Paginated transaction list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {"type": "array", "items": {"$ref": "#/components/schemas/Transaction"}},
                    "pagination": {"$ref": "#/components/schemas/Pagination"}
                  }
                }
              }
            }
          },
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/transactions/{id}": {
      "get": {
        "tags": ["Transactions"],
        "summary": "Get transaction by ID",
        "description": "Retrieves the full details and current status of a specific swap transaction.",
        "operationId": "getTransaction",
        "security": [{"ApiKey": []}],
        "parameters": [
          {"name": "id", "in": "path", "required": true, "schema": {"type": "string"}, "example": "a1b2c3d4e5"}
        ],
        "responses": {
          "200": {
            "description": "Transaction object",
            "content": {
              "application/json": {
                "schema": {"$ref": "#/components/schemas/Transaction"}
              }
            }
          },
          "404": {"description": "Transaction not found"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Bearer token. Format: 'Authorization: Bearer YOUR_API_KEY'. Obtain via /api-docs.php contact form."
      }
    },
    "schemas": {
      "Currency": {
        "type": "object",
        "properties": {
          "code":     {"type": "string", "example": "XMR"},
          "name":     {"type": "string", "example": "Monero"},
          "icon":     {"type": "string", "format": "uri"},
          "network":  {"type": "string", "example": "Monero"},
          "depositMin": {"type": "number"},
          "depositMax": {"type": "number"}
        }
      },
      "CurrencyListResponse": {
        "type": "object",
        "properties": {
          "data":       {"type": "array", "items": {"$ref": "#/components/schemas/Currency"}},
          "pagination": {"$ref": "#/components/schemas/Pagination"}
        }
      },
      "RateResponse": {
        "type": "object",
        "properties": {
          "coinFrom":     {"type": "string", "example": "BTC"},
          "coinTo":       {"type": "string", "example": "XMR"},
          "amount":       {"type": "number", "example": 0.1},
          "amountTo":     {"type": "number", "example": 65.4321, "description": "Estimated amount the user will receive"},
          "rate":         {"type": "number"},
          "minAmount":    {"type": "number"},
          "maxAmount":    {"type": "number"},
          "fee":          {"type": "number"},
          "rateType":     {"type": "string", "enum": ["fixed", "float"]}
        }
      },
      "CreateTransactionRequest": {
        "type": "object",
        "required": ["coinFrom", "coinTo", "amount", "withdrawalAddress"],
        "properties": {
          "coinFrom":           {"type": "string", "example": "BTC"},
          "coinTo":             {"type": "string", "example": "XMR"},
          "amount":             {"type": "number", "example": 0.1},
          "withdrawalAddress":  {"type": "string", "description": "Destination wallet address (where the user will receive coinTo)"},
          "refundAddress":      {"type": "string", "description": "Optional refund address (in coinFrom network)"},
          "rateType":           {"type": "string", "enum": ["fixed", "float"], "default": "float"}
        }
      },
      "Transaction": {
        "type": "object",
        "properties": {
          "id":                {"type": "string", "example": "a1b2c3d4e5"},
          "status":            {"type": "string", "enum": ["wait", "confirmation", "confirmed", "exchanging", "sending", "success", "overdue", "refunded"]},
          "coinFrom":          {"type": "string"},
          "coinTo":            {"type": "string"},
          "amount":            {"type": "number"},
          "amountTo":          {"type": "number"},
          "depositAddress":    {"type": "string"},
          "withdrawalAddress": {"type": "string"},
          "refundAddress":     {"type": "string"},
          "createdAt":         {"type": "string", "format": "date-time"},
          "updatedAt":         {"type": "string", "format": "date-time"},
          "rate":              {"type": "number"},
          "rateType":          {"type": "string", "enum": ["fixed", "float"]}
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "page":  {"type": "integer"},
          "size":  {"type": "integer"},
          "total": {"type": "integer"}
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error":   {"type": "string"},
          "message": {"type": "string"},
          "code":    {"type": "integer"}
        }
      }
    },
    "responses": {
      "BadRequest":    {"description": "Bad request (invalid parameters)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "Unauthorized":  {"description": "Missing or invalid API key",       "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "RateLimited":   {"description": "Rate limit exceeded (HTTP 429)",   "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}
    }
  }
}
