---
title: Market Data Tools
description: Real-time prices, analytics, and on-chain data from 17+ sources
---
# Market Data Tools
Access **17 market data sources** with **50+ data tools** for prices, analytics, on-chain metrics, and market intelligence.
## Price Feeds (17 sources)
### CoinGecko
**`coingecko_get_price`** - Get token price
```typescript
{
ids: string[]; // Coin IDs
vs_currencies: string[]; // USD, EUR, BTC
include_market_cap?: boolean;
include_24hr_vol?: boolean;
include_24hr_change?: boolean;
}
```
**`coingecko_get_market_chart`** - Historical prices
```typescript
{
id: string;
vs_currency: string;
days: number; // 1, 7, 30, 90, 365, max
}
```
### CoinMarketCap
**`cmc_get_quotes`** - Get latest quotes
```typescript
{
id?: string; // CMC ID
symbol?: string; // Symbol (BTC, ETH)
convert: string; // USD, EUR
}
```
**`cmc_get_trending`** - Get trending tokens
```typescript
{
limit?: number;
time_period?: '24h' | '7d' | '30d';
}
```
### Chainlink Price Feeds
**`chainlink_get_price`** - Get oracle price
```typescript
{
pair: string; // ETH/USD, BTC/USD
chainId: number;
}
```
**`chainlink_get_round_data`** - Historical round data
```typescript
{
feed: string; // Feed address
roundId: number;
chainId: number;
}
```
### Pyth Network
**`pyth_get_price`** - Get Pyth price
```typescript
{
priceId: string; // Price feed ID
}
// Returns: price, conf, expo, publishTime
```
## On-Chain Analytics (12 platforms)
### Dune Analytics
**`dune_execute_query`** - Run Dune query
```typescript
{
queryId: number;
parameters?: Record<string, any>;
}
```
**`dune_get_results`** - Get query results
```typescript
{
executionId: string;
}
```
### The Graph
**`graph_query`** - Query subgraph
```typescript
{
subgraphId: string;
query: string; // GraphQL query
variables?: Record<string, any>;
}
```
### Nansen
**`nansen_get_wallet_profiler`** - Profile wallet
```typescript
{
address: string;
chainId: number;
}
// Returns: labels, activity, holdings
```
**`nansen_get_smart_money`** - Track smart money flows
```typescript
{
token?: string;
timeframe: '1h' | '24h' | '7d';
}
```
### DeFi Llama
**`defillama_get_tvl`** - Get protocol TVL
```typescript
{
protocol: string; // Protocol slug
}
```
**`defillama_get_chains`** - Get chain TVLs
```typescript
{} // Returns all chains with TVL
```
**`defillama_get_yields`** - Get yield opportunities
```typescript
{
chain?: string;
project?: string;
minTvl?: number;
}
```
## Block Explorers (8 integrations)
### Etherscan
**`etherscan_get_tx`** - Get transaction
```typescript
{
txhash: string;
chainId: number;
}
```
**`etherscan_get_token_holders`** - Get token holders
```typescript
{
contractAddress: string;
page?: number;
offset?: number;
}
```
**`etherscan_get_contract_abi`** - Get verified ABI
```typescript
{
address: string;
chainId: number;
}
```
### Solscan
**`solscan_get_account`** - Get Solana account
```typescript
{
address: string;
}
```
**`solscan_get_token_holders`** - Get SPL token holders
```typescript
{
tokenAddress: string;
offset?: number;
limit?: number;
}
```
## Advanced Analytics
### Token Analysis
**`analyze_token`** - Deep token analysis
```typescript
{
address: string;
chainId: number;
}
// Returns: liquidity, holders, transactions, risk score
```
**`get_holder_distribution`** - Holder distribution analysis
```typescript
{
token: string;
chainId: number;
}
// Returns: top holders, distribution chart, concentration
```
### Wallet Analysis
**`analyze_wallet`** - Wallet profiling
```typescript
{
address: string;
chainId: number;
}
// Returns: balance, history, labels, risk score
```
**`get_wallet_pnl`** - Calculate wallet P&L
```typescript
{
address: string;
token?: string; // Specific token or all
chainId: number;
}
```
### Market Sentiment
**`get_fear_greed_index`** - Crypto fear & greed index
```typescript
{
limit?: number; // Historical data points
}
```
**`get_social_sentiment`** - Social media sentiment
```typescript
{
token: string;
platforms: ('twitter' | 'reddit' | 'telegram')[];
}
```
## Usage Examples
### Multi-Source Price Aggregation
```typescript
import { marketData } from '@universal-crypto/tools';
async function getAggregatedPrice(token: string) {
const [cgPrice, cmcPrice, chainlinkPrice] = await Promise.all([
marketData.coingecko_get_price({
ids: [token],
vs_currencies: ['usd']
}),
marketData.cmc_get_quotes({
symbol: token.toUpperCase()
}),
marketData.chainlink_get_price({
pair: `${token.toUpperCase()}/USD`,
chainId: 1
}),
]);
// Calculate average (excluding outliers)
const prices = [cgPrice, cmcPrice, chainlinkPrice];
const average = prices.reduce((a, b) => a + b) / prices.length;
const stdDev = Math.sqrt(
prices.reduce((sq, n) => sq + Math.pow(n - average, 2), 0) / prices.length
);
return {
price: average,
confidence: 1 / stdDev, // Higher = more agreement
sources: { coingecko: cgPrice, cmc: cmcPrice, chainlink: chainlinkPrice },
};
}
```
### Smart Money Tracker
```typescript
// Track what smart money is buying
async function trackSmartMoney() {
const flows = await marketData.nansen_get_smart_money({
timeframe: '24h',
});
// Get detailed analysis for top tokens
const analyses = await Promise.all(
flows.slice(0, 10).map(token =>
marketData.analyze_token({
address: token.address,
chainId: 1,
})
)
);
// Filter high-quality opportunities
const opportunities = analyses.filter(a =>
a.riskScore < 30 &&
a.liquidity > 1000000 &&
a.holders > 1000
);
return opportunities;
}
```
### DeFi Yield Optimizer
```typescript
// Find best yields across protocols
async function findBestYields(asset: string) {
const yields = await marketData.defillama_get_yields({
minTvl: 1000000, // Min $1M TVL
});
// Filter by asset
const assetYields = yields.filter(y =>
y.symbol.toLowerCase().includes(asset.toLowerCase())
);
// Sort by APY
const sorted = assetYields.sort((a, b) => b.apy - a.apy);
// Get top 5 with analysis
const top5 = await Promise.all(
sorted.slice(0, 5).map(async y => ({
...y,
analysis: await marketData.analyze_protocol({
protocol: y.project,
}),
}))
);
return top5;
}
```
### On-Chain Activity Monitor
```typescript
// Monitor whale transactions
async function monitorWhales(token: string) {
const holders = await marketData.etherscan_get_token_holders({
contractAddress: token,
offset: 100, // Top 100 holders
});
// Watch for large transfers
const whaleAddresses = holders.slice(0, 10).map(h => h.address);
// Subscribe to transactions
for (const whale of whaleAddresses) {
const txs = await marketData.etherscan_get_txlist({
address: whale,
startblock: 'latest',
});
// Alert on large transfers
const largeTxs = txs.filter(tx =>
parseFloat(tx.value) > 100000 // > $100k
);
if (largeTxs.length > 0) {
console.log(`🐋 Whale activity detected!`);
console.log(largeTxs);
}
}
}
```
## Data Source Comparison
| Source | Coverage | Latency | Cost | Reliability |
|--------|----------|---------|------|-------------|
| **CoinGecko** | 10,000+ coins | ~30s | Free | ⭐⭐⭐⭐ |
| **CoinMarketCap** | 9,000+ coins | ~30s | Free tier | ⭐⭐⭐⭐⭐ |
| **Chainlink** | 200+ pairs | Real-time | On-chain | ⭐⭐⭐⭐⭐ |
| **Pyth** | 400+ pairs | <1s | On-chain | ⭐⭐⭐⭐⭐ |
| **DeFi Llama** | 3,000+ protocols | ~5m | Free | ⭐⭐⭐⭐ |
| **Dune** | Custom queries | Varies | Paid | ⭐⭐⭐⭐ |
| **The Graph** | Subgraphs | Real-time | Paid | ⭐⭐⭐⭐⭐ |
| **Nansen** | Analytics | Real-time | Paid | ⭐⭐⭐⭐⭐ |
## Pricing
| Tool Category | Cost | Rate Limit |
|---------------|------|------------|
| Public APIs | Free | Varies (60-100/min) |
| Premium APIs | $0.001-0.01/call | Higher limits |
| On-chain data | Free | Blockchain dependent |
| Analytics | $0.01-0.10/query | Custom |
## Next Steps
- [Price Feed Integration](/guides/market-data/prices) - Integrate price feeds
- [Analytics Dashboard](/guides/market-data/analytics) - Build dashboards
- [Alert System](/guides/market-data/alerts) - Set up price alerts
- [Data Aggregation](/guides/market-data/aggregation) - Multi-source strategies