{
  "openapi": "3.1.0",
  "info": {
    "title": "Bridge Crypto public API",
    "version": "1.0.0",
    "description": "Read-only public endpoints for supported chains, fees, limits, and 1:1 USDC/USDT route quotes. These endpoints do not create orders or move funds. Creating a transfer requires a signed-in wallet and a source transaction signed by that wallet. AI agents that control their own wallet can use the MCP endpoint at https://bridgecrypto.io/mcp; see https://bridgecrypto.io/ai-agents/.",
    "contact": {
      "name": "Bridge Crypto",
      "email": "fuxiaobao@gmail.com",
      "url": "https://bridgecrypto.io/"
    },
    "x-mcp-endpoint": "https://bridgecrypto.io/mcp"
  },
  "servers": [
    {
      "url": "https://bridgecrypto.io",
      "description": "Production"
    },
    {
      "url": "http://127.0.0.1:8080",
      "description": "Local development"
    }
  ],
  "tags": [
    {
      "name": "Public",
      "description": "No authentication required. Read-only."
    }
  ],
  "paths": {
    "/api/v1/config": {
      "get": {
        "operationId": "getConfig",
        "summary": "Supported chains, tokens, fees, and limits",
        "tags": ["Public"],
        "responses": {
          "200": {
            "description": "Public chain and fee configuration",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Config" }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote": {
      "get": {
        "operationId": "quoteBridge",
        "summary": "Quote a 1:1 USDC or USDT route",
        "description": "Returns the destination fee and receive amount for a route. Optionally validates a destination address. This does not create an order or move funds.",
        "tags": ["Public"],
        "parameters": [
          {
            "name": "fromChain",
            "in": "query",
            "required": true,
            "description": "Source chain key",
            "schema": { "type": "string", "example": "base" }
          },
          {
            "name": "fromToken",
            "in": "query",
            "required": true,
            "description": "USDC or USDT",
            "schema": { "type": "string", "enum": ["USDC", "USDT"], "example": "USDC" }
          },
          {
            "name": "toChain",
            "in": "query",
            "required": true,
            "description": "Destination chain key",
            "schema": { "type": "string", "example": "tron" }
          },
          {
            "name": "toToken",
            "in": "query",
            "required": true,
            "description": "USDC or USDT; it must differ from the source token when the chains are the same",
            "schema": { "type": "string", "enum": ["USDC", "USDT"], "example": "USDT" }
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "description": "Human-readable amount with up to 6 decimal places",
            "schema": { "type": "string", "example": "100" }
          },
          {
            "name": "destAddress",
            "in": "query",
            "required": false,
            "description": "Optional destination wallet address to validate for the destination chain",
            "schema": { "type": "string", "example": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE" }
          }
        ],
        "responses": {
          "200": {
            "description": "Route quote",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/QuoteResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid route, amount, or destination address",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "operationId": "healthz",
        "summary": "API and database health",
        "tags": ["Public"],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "status": { "type": "string", "example": "ok" } }
                }
              }
            }
          },
          "503": {
            "description": "Database unavailable",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "code": {
            "type": "string",
            "examples": ["INVALID_QUOTE", "INVALID_DESTINATION", "RATE_LIMITED"]
          }
        },
        "required": ["error"]
      },
      "Token": {
        "type": "object",
        "properties": {
          "symbol": { "type": "string", "examples": ["USDC", "USDT"] },
          "address": { "type": "string" },
          "decimals": { "type": "integer" }
        },
        "required": ["symbol", "address", "decimals"]
      },
      "Chain": {
        "type": "object",
        "properties": {
          "key": { "type": "string", "examples": ["ethereum", "base", "arbitrum", "polygon", "plasma", "arc", "solana", "tron"] },
          "name": { "type": "string" },
          "chainId": { "type": "integer" },
          "chainType": { "type": "string", "enum": ["evm", "solana", "tron"] },
          "nativeSymbol": { "type": "string" },
          "nativeDecimals": { "type": "integer" },
          "explorer": { "type": "string" },
          "publicRpc": { "type": "string" },
          "confirmations": { "type": "integer" },
          "payoutConfirmations": { "type": "integer" },
          "canSource": { "type": "boolean" },
          "canDest": { "type": "boolean" },
          "depositAddress": { "type": "string" },
          "tokens": { "type": "array", "items": { "$ref": "#/components/schemas/Token" } }
        },
        "required": ["key", "name", "chainType", "canSource", "canDest", "tokens"]
      },
      "Config": {
        "type": "object",
        "properties": {
          "chains": { "type": "array", "items": { "$ref": "#/components/schemas/Chain" } },
          "feeUnits": { "type": "string", "example": "1" },
          "fees": { "type": "object", "additionalProperties": { "type": "string" }, "example": { "tron": "2" } },
          "minAmount": { "type": "string", "example": "5" },
          "maxAmount": { "type": "string", "example": "100000" }
        },
        "required": ["chains", "feeUnits", "fees", "minAmount", "maxAmount"]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "fromChain": { "type": "string" },
          "fromChainName": { "type": "string" },
          "fromChainType": { "type": "string", "enum": ["evm", "solana", "tron"] },
          "fromChainId": { "type": "integer" },
          "fromToken": { "type": "string" },
          "fromTokenContract": { "type": "string" },
          "fromTokenDecimals": { "type": "integer" },
          "toChain": { "type": "string" },
          "toChainName": { "type": "string" },
          "toChainType": { "type": "string", "enum": ["evm", "solana", "tron"] },
          "toChainId": { "type": "integer" },
          "toToken": { "type": "string" },
          "toTokenContract": { "type": "string" },
          "toTokenDecimals": { "type": "integer" },
          "amount": { "type": "string", "example": "100" },
          "amountRaw": { "type": "string", "example": "100000000" },
          "fee": { "type": "string", "example": "2" },
          "feeRaw": { "type": "string" },
          "feeUnits": { "type": "string" },
          "receive": { "type": "string", "example": "98" },
          "receiveRaw": { "type": "string" },
          "minAmount": { "type": "string" },
          "maxAmount": { "type": "string" },
          "rate": { "type": "string", "const": "1:1" },
          "depositAddress": { "type": "string", "description": "Source-chain platform deposit address" },
          "sourceExplorer": { "type": "string" },
          "destExplorer": { "type": "string" }
        },
        "required": [
          "fromChain", "fromChainType", "fromToken", "toChain", "toChainType",
          "toToken", "amount", "amountRaw", "fee", "feeRaw", "receive",
          "receiveRaw", "rate", "depositAddress"
        ]
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "quote": { "$ref": "#/components/schemas/Quote" },
          "destAddressValid": {
            "type": "boolean",
            "description": "Present and true when destAddress was supplied and passed validation"
          }
        },
        "required": ["quote"]
      }
    }
  },
  "externalDocs": {
    "description": "AI agents and MCP guide",
    "url": "https://bridgecrypto.io/ai-agents/"
  }
}
