Skip to content

Latest commit

 

History

History
130 lines (111 loc) · 2.9 KB

API-INTEGRATION.md

File metadata and controls

130 lines (111 loc) · 2.9 KB

API Integration Guide for Frontend

Quick Start

API Base URL: http://localhost:3001/api/v1

Available Endpoints

1. Get Yield Comparison Data

GET /yields/comparison
Query params: ?assets=AAPL,TSLA&protocols=kamino,falcon-finance

Response:

{
  "data": [
    {
      "id": 1,
      "name": "AAPL Kamino Yield Strategy",
      "strategyType": "variable-rate",
      "description": "...",
      "howItWorks": "Step-by-step text...",
      "minDeposit": "100",
      "lockupPeriod": 0,
      "protocol": {
        "id": 4,
        "name": "Kamino",
        "slug": "kamino",
        "websiteUrl": "https://kamino.finance",
        "affiliateLink": "https://kamino.finance?ref=xstocks",
        "riskScore": "3.5"
      },
      "asset": {
        "id": 3,
        "symbol": "AAPL",
        "name": "Apple Inc.",
        "iconUrl": "/assets/aapl.svg"
      },
      "currentYield": {
        "apy": "8.92",
        "apy7dAvg": "8.67",
        "apy30dAvg": "8.45",
        "tvl": "1200000.50",
        "recordedAt": "2026-01-26T10:30:00.000Z"
      },
      "riskMetric": {
        "smartContractRisk": "3.0",
        "liquidityRisk": "3.5",
        "protocolRisk": "3.0",
        "marketRisk": "4.0",
        "overallRiskScore": "3.4",
        "riskLabel": "Medium",
        "lastAuditDate": "2025-12-15T00:00:00.000Z",
        "auditFirm": "Certik"
      }
    }
  ]
}

2. Get Single Strategy

GET /strategies/:id

Response: Same structure as single item above.

3. Manual Yield Sync

POST /yields/sync
Body (optional): { "protocols": ["kamino", "raydium"] }

Response:

{
  "success": true,
  "synced": 20,
  "failed": 0,
  "timestamp": "2026-01-26T10:30:00.000Z",
  "updates": [
    {
      "strategyId": 1,
      "strategyName": "AAPL Kamino",
      "assetSymbol": "AAPL",
      "protocolSlug": "kamino",
      "oldAPY": 8.92,
      "newAPY": 8.97,
      "change": 0.05,
      "success": true
    }
  ]
}

Key Data Points

Assets: AAPL, TSLA, GOOGL, MSFT, NVDA

Protocols: kamino, falcon-finance, raydium, termmax

Risk Levels: Low (1-3), Medium (4-6), High (7-10)

Total Strategies: 20 (5 assets × 4 protocols)

UI Requirements

Homepage - Comparison Table

  • Display all 20 strategies in sortable table
  • Default sort: APY descending
  • Filters: By asset, by protocol
  • Show: Asset, Protocol, APY (with 24h change), Risk badge, TVL
  • Click row → navigate to strategy detail page
  • "Sync Data" button → calls POST /yields/sync

Strategy Detail Page

  • Full strategy info from GET /strategies/:id
  • Display risk breakdown (visual bars)
  • Show "How It Works" steps
  • "Earn Now" button → opens affiliateLink in new tab

Notes

  • All APY values are percentages (8.92 = 8.92%)
  • TVL is in dollars (raw number, format as $1.2M)
  • Timestamps are ISO 8601 format
  • Risk labels: "Low", "Medium", "High"
  • affiliateLink includes tracking param (?ref=xstocks)