{
 "openapi": "3.1.0",
 "info": {
  "title": "feeless.money exchange route comparison",
  "version": "1.0.0",
  "description": "Every sensible route to exchange or transfer an amount between EUR, USD, TZS, USDT, USDC, BTC, ETH and Nano (XNO): final amount, total cost against the market rate, duration, KYC, and the source, time and kind (executable | indicative | manual) of every number. Same calculation as the web page. Paid per call via x402 in Nano (XNO); without payment the API answers 402 with the price."
 },
 "servers": [{ "url": "https://feeless.money/exchange" }],
 "paths": {
  "/api/routes": {
   "get": {
    "summary": "Compare all routes for an amount",
    "parameters": [
     { "name": "from", "in": "query", "required": true, "schema": { "type": "string", "enum": ["EUR", "USD", "TZS", "USDT", "USDC", "BTC", "ETH", "XNO"] } },
     { "name": "to", "in": "query", "required": true, "schema": { "type": "string", "enum": ["EUR", "USD", "TZS", "USDT", "USDC", "BTC", "ETH", "XNO"] } },
     { "name": "amount", "in": "query", "required": false, "schema": { "type": "string", "default": "100", "pattern": "^[0-9]+(\\.[0-9]+)?$" } },
     { "name": "payout", "in": "query", "required": false, "schema": { "type": "string", "enum": ["bank", "mobile", "wallet"] } },
     { "name": "X-PAYMENT", "in": "header", "required": false, "description": "x402 payment payload (Nano)", "schema": { "type": "string" } }
    ],
    "responses": {
     "200": { "description": "Routes, sorted by final amount (ranked first). Amounts are decimal strings; null means no data.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Comparison" } } } },
     "400": { "description": "Invalid input" },
     "402": { "description": "Payment required (x402)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PaymentRequired" } } } }
    }
   }
  },
  "/api/quotes": {
   "get": {
    "summary": "All raw quotes with source, fetched_at (UTC) and kind",
    "parameters": [{ "name": "X-PAYMENT", "in": "header", "required": false, "schema": { "type": "string" } }],
    "responses": { "200": { "description": "quotes.json" }, "402": { "description": "Payment required (x402)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PaymentRequired" } } } } }
   }
  }
 },
 "components": {
  "schemas": {
   "PaymentRequired": {
    "type": "object",
    "properties": {
     "x402Version": { "type": "integer" },
     "error": { "type": "string" },
     "accepts": { "type": "array", "items": { "type": "object", "properties": {
      "scheme": { "type": "string" }, "network": { "type": "string", "const": "nano" }, "asset": { "type": "string", "const": "XNO" },
      "amount_xno": { "type": "string" }, "maxAmountRequired": { "type": "string", "description": "raw units, 1 XNO = 10^30 raw" },
      "payTo": { "type": ["string", "null"] }, "resource": { "type": "string" }, "description": { "type": "string" } } } }
    }
   },
   "Comparison": {
    "type": "object",
    "properties": {
     "input": { "type": "object" },
     "computed_at": { "type": "string", "format": "date-time" },
     "quotes_generated_at": { "type": ["string", "null"] },
     "market": { "type": ["object", "null"], "properties": { "rate": { "type": "string" }, "out": { "type": "string" } } },
     "nano_hint": { "type": ["object", "null"] },
     "intermediates": { "type": "array" },
     "routes": { "type": "array", "items": { "type": "object", "properties": {
      "id": { "type": "string" }, "status": { "type": "string", "enum": ["ok", "nodata", "expired", "too_small"] },
      "ranked": { "type": "boolean" }, "final": { "type": ["string", "null"] }, "cost_pct": { "type": ["string", "null"] },
      "cost_start": { "type": ["string", "null"] }, "gain": { "type": ["boolean", "null"] },
      "duration": { "type": ["array", "null"], "description": "[min, max] minutes" }, "exchanges": { "type": "integer" },
      "kyc": { "type": "string", "enum": ["yes", "no", "unknown"] }, "data_time": { "type": ["string", "null"] },
      "stale": { "type": "boolean" }, "manual_old": { "type": "boolean" }, "unverified": { "type": "boolean" },
      "missing": { "type": "array", "items": { "type": "string" } }, "steps": { "type": "array" } } } }
    }
   }
  }
 }
}
