Guides
Practical tutorials for common integration patterns.
Track a Wallet in Real-Time
Combine the REST API with WebSocket streams to build a wallet tracker:
- Fetch current open positions via
GET /v1/wallets/{address}/positions?status=open - Fetch unrealized PnL via
GET /v1/wallets/{address}/unrealized-pnlto see current gains/losses on those positions - Connect to the WebSocket and subscribe to
wallet:{address}:pnl,wallet:{address}:unrealized-pnl, andwallet:{address}:positions - Update your local state as events arrive — realized PnL when trades close, unrealized PnL as prices move
import asyncio
import json
import requests
import websockets
API_KEY = "YOUR_API_KEY"
WALLET = "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
# Step 1: Fetch current state
positions = requests.get(
f"https://api.conyr.ai/v1/wallets/{WALLET}/positions",
headers={"Authorization": f"Bearer {API_KEY}"},
params={"status": "open"},
).json()["positions"]
print(f"Currently holding {len(positions)} positions")
# Step 2: Stream updates
async def stream_updates():
async with websockets.connect("wss://api.conyr.ai/ws") as ws:
await ws.send(json.dumps({
"op": "subscribe",
"channels": [
f"wallet:{WALLET}:pnl",
f"wallet:{WALLET}:unrealized-pnl",
f"wallet:{WALLET}:positions",
]
}))
async for msg in ws:
event = json.loads(msg)
if "channel" in event:
if ":pnl" in event["channel"] and "unrealized" not in event["channel"]:
print(f"Trade closed: PnL ${event['data'].get('realized_pnl_usd', 0):.2f}")
elif "unrealized-pnl" in event["channel"]:
print(f"Unrealized PnL: ${event['data'].get('total_unrealized_pnl_usd', 0):.2f}")
elif "positions" in event["channel"]:
print(f"Position update: {event['data']}")
asyncio.run(stream_updates())Build a Token Dashboard
Fetch token info, OHLCV data, and recent trades to power a dashboard:
const API_KEY = "YOUR_API_KEY";
const MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
const headers = { Authorization: `Bearer ${API_KEY}` };
// Fetch all data in parallel
const [info, ohlcv, trades] = await Promise.all([
fetch(`https://api.conyr.ai/v1/tokens/${MINT}/info`, { headers }).then(r => r.json()),
fetch(`https://api.conyr.ai/v1/tokens/${MINT}/ohlcv?timeframe=5m&limit=200`, { headers }).then(r => r.json()),
fetch(`https://api.conyr.ai/v1/tokens/${MINT}/trades?limit=50`, { headers }).then(r => r.json()),
]);
console.log("Validated:", info.is_validated, "Suspicious:", info.is_suspicious);
console.log("Candles:", ohlcv.candles.length);
console.log("Recent trades:", trades.trades.length);Find Top Performers and Analyze Their Trades
import requests
API_KEY = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {API_KEY}"}
# Get top 10 by ROI
lb = requests.get(
"https://api.conyr.ai/v1/leaderboard",
headers=headers,
params={"window": "7d", "sort": "roi", "limit": 10},
).json()
for entry in lb["leaderboard"]:
wallet = entry["wallet_address"]
# Get their labels
labels = requests.get(
f"https://api.conyr.ai/v1/wallets/{wallet}/labels",
headers=headers,
).json()
trader_type = labels.get("trader_type", "unknown") if labels else "unclassified"
print(f"#{entry['rank']} {wallet[:12]}... "
f"ROI: {entry['roi']:.1f}% | Type: {trader_type}")