Overview
The ETFs API provides comprehensive data for exchange-traded funds, including fund details, holdings information, and sector/geographic exposure analysis.
Methods
fund()
Get detailed fund information for a specific ETF.
const axion = new Axion('your-api-key');
// Get SPY fund information
const spyFund = await axion.etfs.fund('SPY');
// Get QQQ fund information
const qqqFund = await axion.etfs.fund('QQQ');
// Get VTI fund information
const vtiFund = await axion.etfs.fund('VTI');
The ETF ticker symbol (e.g., ‘SPY’, ‘QQQ’, ‘VTI’)
Detailed ETF fund informationFund description and investment objective
Dividend yield percentage
Average daily trading volume
holdings()
Get the top holdings of an ETF.
const axion = new Axion('your-api-key');
// Get SPY holdings
const spyHoldings = await axion.etfs.holdings('SPY');
// Get ARK Innovation holdings
const arkHoldings = await axion.etfs.holdings('ARKK');
// Get bond ETF holdings
const bondHoldings = await axion.etfs.holdings('AGG');
The ETF ticker symbol (e.g., ‘SPY’, ‘ARKK’, ‘AGG’)
Array of holding objectsTicker symbol of the holding
Portfolio weight percentage
Market value of the holding
Type of asset (stock, bond, etc.)
exposure()
Get sector and geographic exposure breakdown for an ETF.
const axion = new Axion('your-api-key');
// Get SPY sector exposure
const spyExposure = await axion.etfs.exposure('SPY');
// Get technology ETF exposure
const techExposure = await axion.etfs.exposure('XLK');
// Get international ETF exposure
const intlExposure = await axion.etfs.exposure('VXUS');
The ETF ticker symbol (e.g., ‘SPY’, ‘XLK’, ‘VXUS’)
Exposure breakdown informationSector exposure breakdownPercentage allocation to this sector
Geographic exposure breakdownPercentage allocation to this country
Asset class breakdownPercentage allocation to this asset class
Example: ETF Portfolio Analyzer
import { Axion } from 'axion-sdk';
const axion = new Axion('your-api-key');
interface PortfolioPosition {
ticker: string;
shares: number;
}
async function analyzeETFPortfolio(positions: PortfolioPosition[]) {
let totalValue = 0;
const portfolio = [];
for (const position of positions) {
const fundInfo = await axion.etfs.fund(position.ticker);
const value = fundInfo.data.price * position.shares;
totalValue += value;
portfolio.push({
ticker: position.ticker,
name: fundInfo.data.name,
shares: position.shares,
price: fundInfo.data.price,
value: value,
expenseRatio: fundInfo.data.expenseRatio,
dividendYield: fundInfo.data.dividendYield
});
}
// Calculate weighted average metrics
const avgExpenseRatio = portfolio.reduce((sum, p) =>
sum + (p.expenseRatio * (p.value / totalValue)), 0);
const avgDividendYield = portfolio.reduce((sum, p) =>
sum + (p.dividendYield * (p.value / totalValue)), 0);
return {
totalValue,
positions: portfolio,
weightedAvgExpenseRatio: avgExpenseRatio,
weightedAvgDividendYield: avgDividendYield
};
}
// Analyze a portfolio
const analysis = await analyzeETFPortfolio([
{ ticker: 'SPY', shares: 10 },
{ ticker: 'QQQ', shares: 5 },
{ ticker: 'AGG', shares: 20 }
]);
console.log(`Total Portfolio Value: $${analysis.totalValue.toFixed(2)}`);
console.log(`Avg Expense Ratio: ${analysis.weightedAvgExpenseRatio.toFixed(3)}%`);
console.log(`Avg Dividend Yield: ${analysis.weightedAvgDividendYield.toFixed(2)}%`);
console.log('\nPositions:');
analysis.positions.forEach(p => {
const weight = (p.value / analysis.totalValue) * 100;
console.log(` ${p.ticker}: $${p.value.toFixed(2)} (${weight.toFixed(1)}%)`);
});
Example: ETF Holdings Analysis
import { Axion } from 'axion-sdk';
const axion = new Axion('your-api-key');
async function analyzeTopHoldings(ticker: string, topN: number = 10) {
const [fundInfo, holdings] = await Promise.all([
axion.etfs.fund(ticker),
axion.etfs.holdings(ticker)
]);
const topHoldings = holdings.data.slice(0, topN);
const topHoldingsWeight = topHoldings.reduce((sum, h) => sum + h.weight, 0);
return {
fund: fundInfo.data.name,
ticker,
totalHoldings: holdings.data.length,
topHoldings,
topHoldingsWeight,
concentration: topHoldingsWeight / topN
};
}
// Analyze SPY's top 10 holdings
const holdingsAnalysis = await analyzeTopHoldings('SPY', 10);
console.log(`${holdingsAnalysis.fund} (${holdingsAnalysis.ticker})`);
console.log(`Total Holdings: ${holdingsAnalysis.totalHoldings}`);
console.log(`Top 10 Weight: ${holdingsAnalysis.topHoldingsWeight.toFixed(2)}%`);
console.log('\nTop Holdings:');
holdingsAnalysis.topHoldings.forEach((h, i) => {
console.log(`${i + 1}. ${h.name} (${h.ticker}): ${h.weight.toFixed(2)}%`);
});
Example: Sector Exposure Comparison
import { Axion } from 'axion-sdk';
const axion = new Axion('your-api-key');
async function compareSectorExposure(tickers: string[]) {
const exposures = [];
for (const ticker of tickers) {
const [fundInfo, exposure] = await Promise.all([
axion.etfs.fund(ticker),
axion.etfs.exposure(ticker)
]);
exposures.push({
ticker,
name: fundInfo.data.name,
sectors: exposure.data.sectors
});
}
// Get all unique sectors
const allSectors = new Set<string>();
exposures.forEach(e => {
e.sectors.forEach(s => allSectors.add(s.name));
});
return {
etfs: exposures,
sectors: Array.from(allSectors)
};
}
// Compare sector exposure across different ETFs
const comparison = await compareSectorExposure(['SPY', 'QQQ', 'XLK']);
console.log('Sector Exposure Comparison:\n');
comparison.sectors.forEach(sector => {
console.log(`${sector}:`);
comparison.etfs.forEach(etf => {
const sectorData = etf.sectors.find(s => s.name === sector);
const weight = sectorData ? sectorData.weight.toFixed(2) : '0.00';
console.log(` ${etf.ticker}: ${weight}%`);
});
console.log('');
});
Example: ETF Screener
import { Axion } from 'axion-sdk';
const axion = new Axion('your-api-key');
interface ScreenerCriteria {
maxExpenseRatio?: number;
minDividendYield?: number;
minAUM?: number;
}
async function screenETFs(tickers: string[], criteria: ScreenerCriteria) {
const results = [];
for (const ticker of tickers) {
try {
const fundInfo = await axion.etfs.fund(ticker);
const data = fundInfo.data;
// Apply screening criteria
if (criteria.maxExpenseRatio && data.expenseRatio > criteria.maxExpenseRatio) {
continue;
}
if (criteria.minDividendYield && data.dividendYield < criteria.minDividendYield) {
continue;
}
if (criteria.minAUM && data.aum < criteria.minAUM) {
continue;
}
results.push({
ticker,
name: data.name,
expenseRatio: data.expenseRatio,
dividendYield: data.dividendYield,
aum: data.aum,
price: data.price
});
} catch (error) {
console.error(`Error screening ${ticker}:`, error.message);
}
}
return results;
}
// Screen for low-cost dividend ETFs
const screened = await screenETFs(
['SPY', 'VTI', 'VYM', 'SCHD', 'DVY'],
{
maxExpenseRatio: 0.10,
minDividendYield: 2.0,
minAUM: 1_000_000_000
}
);
console.log('ETFs Meeting Criteria:');
screened.forEach(etf => {
console.log(`${etf.ticker} - ${etf.name}`);
console.log(` Price: $${etf.price.toFixed(2)}`);
console.log(` Expense Ratio: ${etf.expenseRatio}%`);
console.log(` Dividend Yield: ${etf.dividendYield.toFixed(2)}%`);
console.log(` AUM: $${(etf.aum / 1_000_000_000).toFixed(2)}B`);
});
Error Handling
try {
const data = await axion.etfs.fund('INVALID');
} catch (error) {
if (error.message.includes('HTTP Error 404')) {
console.error('ETF not found');
} else if (error.message.includes('Authentication required')) {
console.error('API key is required');
} else {
console.error('An error occurred:', error.message);
}
}