Access DeFi protocols and tokens data through Enso’s API
With Enso API, you can retrieve detailed information about DeFi protocols, tokens, and user balances.
These endpoints enable you to build data-rich applications with comprehensive DeFi protocol information.
Retrieve a list of all protocols supported by Enso, including names, logos, and supported chains.API Reference:GET /v1/protocols
EnsoSDK
Copy
Ask AI
import { EnsoClient } from '@ensofinance/sdk';// Initialize the client with your API keyconst enso = new EnsoClient({ apiKey: 'YOUR_API_KEY' // Replace with your actual API key});// Get all supported protocolsasync function getAllProtocols() { try { const protocols = await enso.getProtocolData(); console.log('Supported protocols:', protocols); return protocols; } catch (error) { console.error('Error fetching protocols:', error); throw error; }}getAllProtocols();
Access detailed information about protocols’ supported actions and standards.
This helps you understand which operations can be performed with specific protocols.API Reference:GET /v1/standards
EnsoSDK
Copy
Ask AI
// Get all available standards (protocols and their actions)async function getProtocolStandards() { try { const response = await fetch('https://api.enso.finance/api/v1/standards', { headers: { 'Authorization': `Bearer ${enso.apiKey}`, 'Content-Type': 'application/json' } }); const standards = await response.json(); console.log('Protocol standards and actions:', standards); return standards; } catch (error) { console.error('Error fetching standards:', error); throw error; }}// Get specific protocol standardasync function getProtocolStandardBySlug(slug) { try { const response = await fetch(`https://api.enso.finance/api/v1/integration/${slug}`, { headers: { 'Authorization': `Bearer ${enso.apiKey}`, 'Content-Type': 'application/json' } }); const standard = await response.json(); console.log(`Standard for ${slug}:`, standard); return standard; } catch (error) { console.error(`Error fetching standard for ${slug}:`, error); throw error; }}getProtocolStandards();getProtocolStandardBySlug('aave-v3');
// Get protocol volume data for a specific chainasync function getChainVolume(chainId: number) { try { const response = await fetch(`https://api.enso.finance/api/v1/volume/${chainId}`, { headers: { 'Authorization': `Bearer ${enso.apiKey}`, 'Content-Type': 'application/json' } }); const volumeData = await response.json(); console.log(`Volume data for chain ${chainId}:`, volumeData); return volumeData; } catch (error) { console.error(`Error fetching volume data for chain ${chainId}:`, error); throw error; }}// Get volume data for EthereumgetChainVolume(1);
The Token API delivers data about DeFi assets including pricing, composition, and yield metrics. Filter tokens by protocol, chain, underlying assets, APY, or TVL to discover specific DeFi opportunities.
Query tokens based on various criteria like protocol, underlying assets, or token type. This helps users discover specific DeFi opportunities.API Reference:GET /v1/tokens
EnsoSDK
Copy
Ask AI
import { EnsoClient } from '@ensofinance/sdk';// Initialize the client with your API keyconst enso = new EnsoClient({ apiKey: 'YOUR_API_KEY' // Replace with your actual API key});// Get Aave V3 DeFi tokens on Ethereum mainnet (chainId 1) with USDT as underlyingasync function getAaveV3UsdtTokensOnEthereum() { try { const tokenData = await enso.getTokenData({ chainId: 1, // Ethereum mainnet protocolSlug: 'aave-v3', type: 'defi', underlyingTokens: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT includeMetadata: true }); console.log('Aave V3 DeFi tokens with USDT as underlying on Ethereum:', tokenData.data); return tokenData.data; } catch (error) { console.error('Error fetching tokens:', error); throw error; }}getAaveV3UsdtTokensOnEthereum();
Access yield and total value locked (TVL) information for DeFi protocols. This data is crucial for comparing investment opportunities across the DeFi landscape.API Reference:GET /v1/tokens with APY filters
EnsoSDK
Copy
Ask AI
import { EnsoClient } from '@ensofinance/sdk';// Initialize the client with your API keyconst enso = new EnsoClient({ apiKey: 'YOUR_API_KEY' // Replace with your actual API key});// Get tokens with APY over 5% for a specific protocolasync function getHighYieldTokensForProtocol(protocolSlug: string, minApy: number = 5) { try { const tokenData = await enso.getTokenData({ chainId: 1, protocolSlug: protocolSlug, type: 'defi', apyFrom: minApy, includeMetadata: true }); console.log(`${protocolSlug} tokens with APY > ${minApy}%:`, tokenData.data); return tokenData.data; } catch (error) { console.error('Error fetching high-yield tokens:', error); throw error; }}getHighYieldTokensForProtocol('yearn');
Retrieve current token prices with confidence scores, supporting decision-making around token swaps and valuations.API Reference:GET /prices/token-price
EnsoSDK
Copy
Ask AI
import { EnsoClient } from '@ensofinance/sdk';// Initialize the client with your API keyconst enso = new EnsoClient({ apiKey: 'YOUR_API_KEY' // Replace with your actual API key});// Get price data for a specific tokenasync function getTokenPrice(chainId: number, tokenAddress: string) { try { const priceData = await enso.getPriceData({ chainId, address: tokenAddress }); console.log(`Price data for ${tokenAddress} on chain ${chainId}:`, priceData); return priceData; } catch (error) { console.error('Error fetching token price:', error); throw error; }}// Get price for WETH on EthereumgetTokenPrice(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
I’ll add the token information use cases with the specified layout and examples:
Retrieve detailed information about multiple tokens in a single request to support portfolio analysis or multi-token operations.API Reference:GET /v1/tokens
Find specific token types with a minimum TVL (Total Value Locked) threshold to focus on well-established and liquid DeFi positions.API Reference:GET /v1/tokens