Workflows & Recipes

Live market intelligence for AI agents

Written by Rishabh Narang, CEO, Hive IntelligenceLast updated

The problem

Your AI agent needs to build a market brief combining spot prices from CoinGecko, exchange-level order flow from CCXT, and DeFi TVL from DeFiLlama. Three providers, three APIs, three schemas. Each has its own auth flow, rate limits, response shape, and failure modes. Your agent spends more time wrestling with API plumbing than doing actual analysis.


Without Hive

Integrating three providers means three different client libraries, three authentication patterns, and three response schemas to normalize before your agent can reason over the data.

python
import requests
import ccxt

# --- Provider 1: CoinGecko for spot prices ---
cg = requests.get("https://api.coingecko.com/api/v3/simple/price",
    params={"ids": "bitcoin,ethereum", "vs_currencies": "usd"}).json()

# --- Provider 2: CCXT for exchange order flow ---
exchange = ccxt.binance()
ticker = exchange.fetch_ticker("BTC/USDT")

# --- Provider 3: DeFiLlama for TVL ---
tvl = requests.get("https://api.llama.fi/v2/protocols").json()
top_protocols = sorted(tvl, key=lambda x: x.get("tvl", 0), reverse=True)[:5]

# Now you need to normalize three different response shapes
# before your agent can build a coherent market brief.
# Each provider has its own rate limits, error codes, and downtime patterns.
# If CoinGecko rate-limits you, your entire pipeline stalls.

That is roughly 30 lines before you even start analysis, and you still need error handling, retry logic, and schema normalization for each provider.


With Hive

Three tool calls through one connection. One API key. One execution contract. One rate limiter.

python
import requests

def hive(tool, args):
    r = requests.post("https://mcp.hiveintelligence.xyz/api/v1/execute",
        headers={"Authorization": "Bearer YOUR_HIVE_API_KEY"},
        json={"tool": tool, "args": args}, timeout=30)
    r.raise_for_status()
    payload = r.json()
    if not payload.get("ok", False):
        raise RuntimeError(payload.get("error", {}).get("message", "Hive call failed"))
    return payload["data"]

prices = hive("get_price", {"ids": "bitcoin,ethereum", "vs_currencies": "usd"})
ticker = hive("get_ticker", {"exchange": "binance", "symbol": "BTC/USDT"})
protocols = hive("get_defi_protocols", {"limit": 5})

Same data. One auth flow. One error format. Your agent focuses on building the market brief, not managing three provider integrations.


Available market intelligence tools

ToolWhat it returns
get_priceSpot prices for any token pair
get_coins_market_dataMarket cap, volume, and 24h change across tokens
get_gainers_losersTop movers in either direction
get_tickerExchange-level order flow and spread data
get_open_interestDerivatives open interest by exchange
get_defi_protocolsDeFi protocol rankings with TVL metrics
get_protocol_tvlCurrent TVL for a specific protocol slug
get_global_statsAggregate crypto market statistics
get_yield_poolsDeFi yield opportunities across protocols

A complete market brief agent

This is the full loop, the kind of daily briefing a portfolio manager or research desk would ask an agent to assemble every morning. Five tool calls through one connection, wrapped in an MCP-compatible prompt.

python
import json, requests

def hive(tool, args):
    r = requests.post("https://mcp.hiveintelligence.xyz/api/v1/execute",
        headers={"Authorization": "Bearer YOUR_HIVE_API_KEY"},
        json={"tool": tool, "args": args}, timeout=30)
    r.raise_for_status()
    payload = r.json()
    if not payload.get("ok", False):
        raise RuntimeError(payload.get("error", {}).get("message", "Hive call failed"))
    return payload["data"]

def daily_brief(watchlist=("bitcoin", "ethereum", "solana")):
    ids = ",".join(watchlist)
    prices    = hive("get_price", {"ids": ids, "vs_currencies": "usd"})
    movers    = hive("get_gainers_losers", {"vs_currency": "usd", "duration": "24h", "top_coins": "1000"})
    protocols = hive("get_defi_protocols", {"limit": 5})
    oi        = hive("get_open_interest", {"exchange": "binance", "symbol": "BTC/USDT:USDT"})
    polymkt   = hive("codex_filter_prediction_markets", {"limit": 3})
    return {
        "watchlist": prices,
        "top_movers": movers,
        "top_tvl": protocols,
        "derivatives_oi": oi,
        "prediction_signals": polymkt,
    }

brief = daily_brief()
print(json.dumps(brief, indent=2))

The same agent through MCP in a supported client such as Claude, Cursor, Windsurf, VS Code, Codex CLI, or Gemini CLI can run the workflow without writing Python. Connect to https://mcp.hiveintelligence.xyz/mcp and prompt:

"Build a daily crypto market brief. Cover spot prices for BTC, ETH, SOL; top gainers and losers over 24h; the top 5 DeFi protocols by TVL; Binance BTC perpetual open interest; and 3 high-volume Polymarket prediction markets. Return as markdown."

The agent discovers the relevant tools through tools/list, chains them, and returns a citable brief. No function schemas to hand-write.


What the output looks like

A typical response assembles into a structured brief that an LLM can summarize or a downstream system can ingest:

json
{
  "watchlist": {
    "bitcoin":  { "usd": 71234.52, "usd_24h_change": 2.41 },
    "ethereum": { "usd":  3890.17, "usd_24h_change": 1.85 },
    "solana":   { "usd":   217.88, "usd_24h_change": 4.12 }
  },
  "top_movers": [ /* ... */ ],
  "top_tvl":    [ /* Aave, Lido, EigenLayer, Uniswap, Maker */ ],
  "derivatives_oi": { "btc_usdt_perp": 12_400_000_000, "eth_usdt_perp": 6_900_000_000 },
  "prediction_signals": [ /* Trump 2028, ETH $5k by EOY, etc. */ ]
}

Hive responses include freshness metadata such as fetched_at where available, so downstream agents can reason about when a snapshot was taken and reduce stale-data mistakes. Hive also centralizes rate-limit handling, provider failover behavior, and schema-discovery metadata so the agent does not have to wire each upstream provider directly.


Why this matters

Every additional provider your agent integrates adds auth configuration, rate-limit handling, schema normalization, and a new failure mode. Hive collapses that to one connection:

  • One API key instead of three sets of credentials
  • One rate limiter instead of juggling per-provider quotas
  • One execution contract instead of writing metadata and error-handling glue for each source
  • One error format instead of catching provider-specific exceptions
  • Runtime tool discovery via MCP tools/list. When Hive adds a new market data tool, your agent picks it up without a redeploy

Your agent focuses on analysis, not API plumbing. Builders who move a research or market-intel agent to Hive typically collapse a 200-to-400 line provider-integration module into a 20-line hive() helper and a thin dispatch function.