DEFI_COPILOT
API Reference

Endpoints

All endpoints are available at https://api.fxjrin.com. Two endpoints require x402 payment; the rest are free.

GET/API info and versionFREE
GET/healthServer status and wallet infoFREE
GET/defi/yield/bestBest yield strategy from Blend0.001 USDC
GET/defi/swap/bestOptimal swap route across DEXes0.001 USDC
GETFREE

/

Returns API version, available endpoints, and pricing information.

response
{
  "name": "DeFi Copilot API",
  "version": "1.1.0",
  "network": "mainnet",
  "endpoints": {
    "GET /defi/yield/best": "0.001 USDC",
    "GET /defi/swap/best": "0.001 USDC"
  }
}
GETFREE

/health

Returns server status, network, and server wallet public key.

response
{
  "status": "ok",
  "network": "mainnet",
  "server_wallet": "GXXXX..."
}
GET0.001 USDC

/defi/yield/best

Returns the best yield strategy for a given asset. APY is fetched live from Blend Finance smart contracts via Soroban RPC — not cached.

Query parameters

ParameterTypeDefaultDescription
assetstringUSDCAsset to find yield for. USDC or XLM.
amountnumber1000Amount to deposit (used for sizing).
example request
curl https://api.fxjrin.com/defi/yield/best?asset=USDC&amount=1000 \ -H 'x-payment: <base64-payment-payload>'
response
{
  "strategy": "Deposit to Fixed V2 on Blend Finance",
  "protocol": "Blend Finance",
  "apy": "9.47%",
  "risk": "low",
  "reasoning": "Live Blend Finance on-chain APY. Pool comparison: Fixed V2: USDC 9.47% | YieldBlox V2: USDC 0.07%",
  "confidence": 0.95,
  "marketData": {
    "xlmPrice": "0.1518 USDC",
    "spread": "0.3945%",
    "volume24h": "4531.6K XLM",
    "source": "Blend Finance (on-chain Soroban) + Stellar mainnet DEX"
  },
  "alternatives": [
    {
      "protocol": "YieldBlox V2",
      "apy": "0.07%",
      "risk": "low"
    }
  ]
}
GET0.001 USDC

/defi/swap/best

Returns the optimal swap route by comparing quotes from three sources: SDEX Orderbook, Stellar DEX pathfinder, and AMM pools — in real time.

Query parameters

ParameterTypeDefaultDescription
fromstringXLMSource asset ticker.
tostringUSDCTarget asset ticker.
amountnumber100Amount of source asset to swap.
example request
curl 'https://api.fxjrin.com/defi/swap/best?from=XLM&to=USDC&amount=500' \ -H 'x-payment: <base64-payment-payload>'
response
{
  "from": "XLM",
  "to": "USDC",
  "amount": 500,
  "route": ["SDEX Orderbook"],
  "expectedOutput": "75.88 USDC",
  "slippage": "0.005%",
  "priceImpact": "low",
  "marketPrice": "1 XLM = 0.1518 USDC",
  "confidence": 0.99,
  "reasoning": "DEX comparison: SDEX Orderbook: 75.88 USDC | Stellar DEX: 75.80 USDC | AMM: 75.70 USDC"
}