Asset Analysis

New
Updated

The Assets namespace gives you access to real-time and historical market data, news, and AI analysis for crypto, stocks, and other asset classes.

In this guide you'll learn how to:

  • Search and list assets
  • Track top market movers
  • Fetch historical prices
  • Read asset news
  • Run AI-powered analysis
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

Find Assets

Search by name or symbol to find assets, then fetch detailed data.

find-assets.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
// Search by name
const { coins } = await chaos.assets.search('uniswap');
console.log(`Found: ${coins?.map(c => c.symbol).join(', ')}`);
 
// Get full details
const eth = await chaos.assets.get('crypto', 'ethereum');
console.log(`${eth.name}: $${eth.price} (${eth.change_percent_24h > 0 ? '+' : ''}${eth.change_percent_24h}%)`);

Market Movers

Track what's moving — top gainers, losers, and trending assets.

market-movers.ts
const { top_gainers, top_losers } = await chaos.assets.topGainersLosers('crypto');
 
console.log('🟢 Top Gainers:');
for (const a of top_gainers.slice(0, 5)) {
  console.log(`  ${a.symbol}: +${a.change_percent_24h.toFixed(1)}%`);
}
 
console.log('\nšŸ”“ Top Losers:');
for (const a of top_losers.slice(0, 5)) {
  console.log(`  ${a.symbol}: ${a.change_percent_24h.toFixed(1)}%`);
}

Historical Prices

Look up asset prices at any point in time using Unix timestamps.

historical-prices.ts
// BTC price on Jan 1, 2024
const price = await chaos.assets.historicalPrice('crypto', 'bitcoin', 1704067200);
 
console.log(`Date: ${price.nearestTradingDay}`);
console.log(`Close: $${price.close}`);
console.log(`Range: $${price.low} — $${price.high}`);

News & AI Analysis

Read recent news and then ask the AI to analyze an asset.

news-analysis.ts
// Get recent news
const news = await chaos.assets.news('crypto', 'ethereum', 5);
for (const article of news) {
  console.log(`šŸ“° ${article.title}`);
}
 
// Run AI analysis
const session = await chaos.assets.analyse(
  'crypto',
  'ethereum',
  'Summarize the key risks and opportunities'
);
console.log(`\nAnalysis session: ${session.sessionId}`);
console.log(`Title: ${session.title}`);
Was this helpful?