English
JavaScript SDK Quick Start Guide
npm install @chainstream-io/dex # or yarn add @chainstream-io/dex
import { DexClient } from '@chainstream-io/dex'; // Initialize the client const client = new DexClient({ accessToken: 'YOUR_ACCESS_TOKEN' });
// Get token details const tokenInfo = await client.token.getToken({ chain: 'sol', tokenAddress: '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN' });
// Subscribe to candle data const unsubscribe = client.stream.subscribeTokenCandles({ chain: 'sol', tokenAddress: '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN', resolution: '1m', callback: (candle) => { console.log('New candle:', candle); } });
// Token swap const swapResult = await client.dex.swap({ chain: 'sol', dex: 'openbook', input_mint: 'INPUT_TOKEN_ADDRESS', output_mint: 'OUTPUT_TOKEN_ADDRESS', amount: '100', slippage: '1' });
Was this page helpful?