Details, History & AI Analysis
Deep-dive into a single asset with full details, look up historical prices at any point in time, read recent news, and start AI-powered analysis sessions.
get(assetType, assetId, startDate?)
Fetch full details for a single asset, including current price, market cap, and 24-hour change.
Parameters:
| Param | Type | Description |
|---|---|---|
assetType | AssetType | The asset class: 'crypto', 'stock', 'etf', etc. |
assetId | string | The asset identifier (e.g., 'bitcoin', 'ethereum'). |
startDate | string | Optional. ISO date string to scope time-series data (e.g., '2024-01-01'). |
Returns: AssetDetails
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
const asset = await chaos.assets.get('crypto', 'ethereum');
console.log(`${asset.name} (${asset.symbol})`);
console.log(`Price: $${asset.price}`);
console.log(`24h Change: ${asset.change_percent_24h > 0 ? '+' : ''}${asset.change_percent_24h}%`);
console.log(`Market Cap: $${asset.market_cap.toLocaleString()}`);
// With a start date for scoped data
const scoped = await chaos.assets.get('crypto', 'ethereum', '2024-06-01');historicalPrice(assetType, assetId, timestamp)
Look up the price of an asset at a specific point in time using a Unix timestamp. The response includes the nearest trading day's OHLC data.
Parameters:
| Param | Type | Description |
|---|---|---|
assetType | AssetType | The asset class. |
assetId | string | The asset identifier. |
timestamp | number | Unix timestamp (seconds) for the target date. |
Returns: HistoricalPriceResponse
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
// BTC price on Jan 1, 2024
const price = await chaos.assets.historicalPrice('crypto', 'bitcoin', 1704067200);
console.log(`Requested: ${price.requestedDate}`);
console.log(`Nearest Trading Day: ${price.nearestTradingDay}`);
console.log(`Close: $${price.close}`);
if (price.open != null) console.log(`Open: $${price.open}`);
if (price.high != null && price.low != null) {
console.log(`Range: $${price.low} — $${price.high}`);
}news(assetType, assetId, limit?)
Get recent news articles about an asset. Each article includes a title, description, tags, and timestamp.
Parameters:
| Param | Type | Description |
|---|---|---|
assetType | AssetType | The asset class. |
assetId | string | The asset identifier. |
limit | number | Optional. Maximum number of articles to return. |
Returns: AssetNews[]
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
const articles = await chaos.assets.news('crypto', 'ethereum', 5);
for (const article of articles) {
console.log(`${article.title}`);
console.log(` ${article.description}`);
console.log(` Tags: ${article.tags.join(', ')}`);
console.log(` Updated: ${article.updated_at}\n`);
}analyse(assetType, assetId, query?)
Start an AI analysis session for an asset. The AI generates a structured analysis that you can render in your application. Optionally pass a natural-language query to focus the analysis on a specific topic.
Parameters:
| Param | Type | Description |
|---|---|---|
assetType | AssetType | The asset class. |
assetId | string | The asset identifier. |
query | string | Optional. A question or topic to focus the analysis on. |
Returns: SessionData
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
// General analysis
const session = await chaos.assets.analyse('crypto', 'bitcoin');
console.log(`Session ID: ${session.sessionId}`);
console.log(`Title: ${session.title}`);
console.log(`Workflow: ${session.workflowName}`);
console.log(`Blocks: ${session.blocks.length}`);
// Focused analysis with a specific question
const riskSession = await chaos.assets.analyse(
'crypto',
'ethereum',
'What are the key risks and opportunities for ETH staking?'
);
console.log(`\nRisk Analysis: ${riskSession.title}`);
console.log(`Created: ${new Date(riskSession.createdAt).toISOString()}`);