API Reference

Complete reference for all Phi Protocol API endpoints

Base URL: https://api-live.phiprotocol.ai

Authentication: API Key required in header: X-API-Key

Format: phi_live_[timestamp][random]

Credit Costs:

  • • Bridge Quote API: 1 credit
  • • Market Data API: 1 credit
  • • Advanced Market Data API: 2 credits
  • • DeFi Intelligence API: 5 credits

Bridge Quote API

GET /bridge/wormhole-quote

Get Wormhole Bridge Quote

Get real-time quotes for cross-chain token transfers via Wormhole.

Query Parameters

Parameter Type Required Description
amount string required Amount to bridge in base units
fromChain string required Source chain (ethereum, solana, polygon, etc.)
toChain string required Destination chain
token string required Token address or symbol

Example Request

GET /api/bridge/wormhole-quote?amount=1000000000&fromChain=solana&toChain=ethereum&token=USDC

Response

200 Success
{
  "success": true,
  "data": {
    "sourceChain": "solana",
    "targetChain": "ethereum",
    "tokenSymbol": "USDC",
    "amountIn": "1000000000",
    "amountOut": "999500000000000000000",
    "estimatedTime": "15 minutes",
    "fees": {
      "bridgeFee": "0.1%",
      "gasFee": "0.0025 ETH"
    }
  }
}
GET /bridge/supported-chains

Get Supported Chains

List all supported blockchain networks for bridging.

Response

200 Success
{
  "success": true,
  "data": {
    "chains": [
      {
        "name": "ethereum",
        "displayName": "Ethereum",
        "chainId": 1,
        "nativeToken": "ETH"
      },
      {
        "name": "solana",
        "displayName": "Solana",
        "chainId": 101,
        "nativeToken": "SOL"
      },
      {
        "name": "polygon",
        "displayName": "Polygon",
        "chainId": 137,
        "nativeToken": "MATIC"
      }
    ]
  }
}

Market Data API

GET /market/prices

Get Token Prices

Get real-time prices for multiple tokens with 24h price changes.

Query Parameters

Parameter Type Required Description
tokens string required Comma-separated token symbols (BTC,ETH,SOL)
currency string optional Price currency (USD, EUR, default: USD)

Example Request

GET /api/market/prices?tokens=BTC,ETH,SOL¤cy=USD

Response

200 Success
{
  "success": true,
  "data": {
    "prices": {
      "BTC": {
        "symbol": "BTC",
        "price": 67420.50,
        "priceChange24h": 2.34,
        "priceChangePercent24h": 3.6,
        "volume24h": 28492847392.12,
        "marketCap": 1329284739201.44,
        "lastUpdate": "2024-01-20T10:30:00Z"
      },
      "ETH": {
        "symbol": "ETH",
        "price": 3245.82,
        "priceChange24h": -45.23,
        "priceChangePercent24h": -1.37,
        "volume24h": 15847293847.83,
        "marketCap": 390284739201.44,
        "lastUpdate": "2024-01-20T10:30:00Z"
      }
    }
  }
}
GET /market/chart

Get Historical Chart Data

Get historical price data for charting and analysis.

Query Parameters

Parameter Type Required Description
symbol string required Token symbol (BTC, ETH, SOL, etc.)
interval string optional Time interval (1h, 4h, 1d, 1w, default: 1d)
limit number optional Number of data points (default: 100, max: 1000)

Example Request

GET /api/market/chart?symbol=BTC&interval=1d&limit=30

Advanced Market Data API

GET /advanced-market-data/liquidity

Get comprehensive liquidity analysis

Analyze liquidity depth across multiple chains and DEXs with professional-grade metrics.

Parameters

Parameter Type Description
token Required string Token symbol (ETH, SOL, BNB, etc.)
chains Optional string Comma-separated chains (default: ethereum,bsc,polygon,avalanche,solana)
depth_levels Optional string Depth levels in millions USD (default: 1,5,10)

Example Request

GET /api/advanced-market-data/liquidity?token=ethereum&chains=ethereum,bsc&depth_levels=1,5,10

Headers:
X-API-Key: phi_live_1234567890abcdef

Response

200
{
  "success": true,
  "data": {
    "token": "ethereum",
    "chains": ["ethereum", "bsc"],
    "liquidity_analysis": {
      "total_liquidity_usd": 2450000000,
      "depth_analysis": {
        "1m": { "price_impact": 0.12, "available": true },
        "5m": { "price_impact": 0.45, "available": true },
        "10m": { "price_impact": 0.89, "available": true }
      }
    }
  },
  "credits_used": 2
}
GET /advanced-market-data/arbitrage

Get arbitrage opportunities

Discover profitable arbitrage opportunities across exchanges with real-time price differentials.

Parameters

Parameter Type Description
token Required string Token symbol to analyze
min_profit Optional string Minimum profit percentage (default: 0.5)
exchanges Optional string Exchanges to analyze (default: all)

Example Request

GET /api/advanced-market-data/arbitrage?token=ethereum&min_profit=1.0

Headers:
X-API-Key: phi_live_1234567890abcdef
GET /advanced-market-data/volatility

Get advanced volatility analysis

Professional volatility metrics including realized, implied, and historical volatility calculations.

Parameters

Parameter Type Description
token Required string Token symbol to analyze
timeframe Optional string Analysis timeframe (default: 24h)
type Optional string Volatility type: realized, implied, historical (default: realized)

Example Request

GET /api/advanced-market-data/volatility?token=ethereum&timeframe=7d&type=realized

Headers:
X-API-Key: phi_live_1234567890abcdef
GET /advanced-market-data/yield-opportunities

Get DeFi yield opportunities

Discover profitable DeFi yield farming and staking opportunities across multiple protocols and chains with risk assessment.

Parameters

Parameter Type Description
token Optional string Token symbol (returns all tokens if not specified)
chains Optional string Comma-separated chains (default: ethereum,bsc,polygon,avalanche,solana)
min_apy Optional string Minimum APY percentage (default: 1)
risk_level Optional string Risk level filter: low, medium, high, all (default: all)

Example Request

GET /api/advanced-market-data/yield-opportunities?token=ethereum&min_apy=5&risk_level=medium

Headers:
X-API-Key: phi_live_1234567890abcdef

Response

200
{
  "success": true,
  "data": {
    "total_opportunities": 12,
    "highest_apy": "18.45%",
    "average_apy": "8.72%",
    "opportunities": [
      {
        "protocol": "Aave",
        "chain": "ethereum",
        "token": "ETH",
        "apy": "12.34%",
        "tvl": "$125.4M",
        "type": "Lending",
        "risk_level": "low",
        "lockup_period": "None",
        "min_deposit": "$100"
      }
    ],
    "risk_distribution": {
      "low": 4,
      "medium": 6,
      "high": 2
    }
  },
  "credits_used": 2
}
GET /advanced-market-data/correlations

Get token correlation analysis

Analyze price correlations between tokens to optimize portfolio diversification and risk management strategies.

Parameters

Parameter Type Description
base_token Required string Base token for correlation analysis
compare_tokens Optional string Comma-separated tokens to compare (default: ethereum,solana,binancecoin)
timeframe Optional string Analysis timeframe: 1d, 7d, 30d, 90d (default: 30d)

Example Request

GET /api/advanced-market-data/correlations?base_token=ethereum&compare_tokens=solana,binancecoin&timeframe=30d

Headers:
X-API-Key: phi_live_1234567890abcdef

Response

200
{
  "success": true,
  "data": {
    "base_token": "ethereum",
    "timeframe": "30d",
    "correlations": {
      "SOL": {
        "correlation": "0.724",
        "strength": "Strong",
        "direction": "Positive",
        "r_squared": "0.524"
      },
      "BNB": {
        "correlation": "0.612",
        "strength": "Moderate",
        "direction": "Positive",
        "r_squared": "0.374"
      }
    },
    "market_insights": {
      "highest_correlation": {
        "token": "SOL",
        "correlation": "0.724"
      },
      "diversification_score": 73,
      "portfolio_risk": "Concentrated"
    }
  },
  "credits_used": 2
}
GET /advanced-market-data/fear-greed

Get Fear & Greed Index

Access comprehensive Fear & Greed Index data with component breakdown and historical analysis for market sentiment tracking.

Parameters

Parameter Type Description
timeframe Optional string Historical timeframe: 1d, 7d, 30d (default: 1d)
include_breakdown Optional boolean Include component breakdown (default: true)

Example Request

GET /api/advanced-market-data/fear-greed?timeframe=7d&include_breakdown=true

Headers:
X-API-Key: phi_live_1234567890abcdef

Response

200
{
  "success": true,
  "data": {
    "current_index": 72,
    "sentiment": "Greed",
    "previous_day": 68,
    "weekly_average": 65,
    "monthly_average": 58,
    "component_breakdown": {
      "volatility": {
        "value": 75,
        "weight": "25%",
        "description": "Current volatility compared to average"
      },
      "market_momentum": {
        "value": 82,
        "weight": "25%",
        "description": "Volume and price momentum"
      },
      "social_media": {
        "value": 68,
        "weight": "15%",
        "description": "Social media sentiment analysis"
      }
    },
    "market_analysis": {
      "trend": "Improving",
      "volatility": "Normal",
      "recommendation": "Monitor market conditions"
    }
  },
  "credits_used": 2
}

DeFi Intelligence API

POST /defi/analysis

Get Comprehensive Market Analysis

Get AI-powered market analysis including technical, on-chain, and sentiment data.

Request Body

Parameter Type Required Description
tokens array required Array of token symbols to analyze
analysisType string optional Analysis type (technical, fundamental, sentiment, all)
timeframe string optional Analysis timeframe (1d, 7d, 30d, default: 7d)

Example Request

{
  "tokens": ["BTC", "ETH", "SOL"],
  "analysisType": "all",
  "timeframe": "7d"
}

Response

200 Success
{
  "success": true,
  "data": {
    "analysis": {
      "overview": "Market showing bullish momentum with strong fundamentals...",
      "technicalAnalysis": {
        "trend": "bullish",
        "support": 65000,
        "resistance": 72000,
        "indicators": {
          "rsi": 58.4,
          "macd": "bullish_crossover",
          "movingAverages": "above_20_50_ma"
        }
      },
      "onChainAnalysis": {
        "activeAddresses": 1234567,
        "transactionVolume": 45678901234,
        "networkActivity": "high",
        "whaleActivity": "accumulating"
      },
      "sentimentAnalysis": {
        "overall": "positive",
        "socialMediaSentiment": 7.2,
        "fearGreedIndex": 68,
        "newsImpact": "positive"
      },
      "riskAssessment": {
        "volatilityScore": 6.5,
        "liquidityScore": 8.9,
        "riskLevel": "medium",
        "recommendations": ["Consider position sizing", "Monitor key support levels"]
      }
    }
  }
}

Error Responses

Common Error Codes

400 Bad Request
{
  "success": false,
  "error": "Invalid request parameters",
  "details": "Missing required field: tokens"
}
401 Unauthorized
{
  "success": false,
  "error": "Invalid API key",
  "details": "Please check your API key and try again"
}
500 Internal Server Error
{
  "success": false,
  "error": "Internal server error",
  "details": "Please try again later or contact support"
}