bloxchaser-sdk
v0.1.0
Published
Official JavaScript/TypeScript SDK for Bloxchaser DEX Data API
Maintainers
Readme
bloxchaser-sdk
Official JavaScript/TypeScript SDK for Bloxchaser - Multi-chain DEX swap data API.
Installation
npm install bloxchaser-sdk
# or
pnpm add bloxchaser-sdk
# or
yarn add bloxchaser-sdkQuick Start
import { Bloxchaser } from 'bloxchaser-sdk';
const client = new Bloxchaser({ apiKey: 'bc_live_your_key' });
// Get recent Solana swaps
const swaps = await client.swaps.get({ chain: 'solana', limit: 100 });
console.log(`Found ${swaps.count} swaps`);
// Get OHLCV for BONK
const ohlcv = await client.swaps.ohlcv(
'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263',
{ interval: '4h' }
);
for (const candle of ohlcv.candles.slice(0, 5)) {
console.log(`${candle.datetime}: ${candle.close}`);
}Features
- Full TypeScript support with complete type definitions
- Works everywhere: Node.js 18+ and modern browsers
- Automatic retry with exponential backoff
- Rate limit handling with smart throttling
- Multi-chain support: Solana, Base, Arbitrum, BNB
API Reference
Swaps
// Get recent swaps
const swaps = await client.swaps.get({
chain: 'solana', // 'solana' | 'base' | 'arbitrum' | 'bnb'
dex: 'raydium', // optional DEX filter
limit: 100,
offset: 0,
});
// Swaps by token
const tokenSwaps = await client.swaps.byToken('So111...', { chain: 'solana' });
// Swaps by pool
const poolSwaps = await client.swaps.byPool('7Xawh...', { chain: 'solana' });
// Chain statistics
const stats = await client.swaps.stats('solana');
// All chains summary
const summary = await client.swaps.chains();
// OHLCV candles (Solana)
const ohlcv = await client.swaps.ohlcv('DezXAZ...', {
quote: 'sol', // 'sol' | 'usdc' | 'usdt'
interval: '4h', // '1m' | '5m' | '15m' | '1h' | '4h' | '1d'
limit: 100,
});Tokens (Solana)
// List tokens
const tokens = await client.tokens.list({ limit: 100 });
// Get token info
const token = await client.tokens.get('DezXAZ...');
// Get current price
const price = await client.tokens.price('DezXAZ...');
// Price history
const history = await client.tokens.priceHistory('DezXAZ...', { limit: 60 });Quotes
// Get swap quote
const quote = await client.quotes.get({
pool: '7Xawh...',
amount: 1_000_000_000, // 1 SOL in lamports
inputToken: 'So111...',
chain: 'solana',
});
console.log(`Output: ${quote.output_amount}, Impact: ${quote.price_impact}`);Health & Usage
// Check API health
const health = await client.health();
console.log(`Status: ${health.status}, Version: ${health.version}`);
// Get your usage stats
const usage = await client.usage();
console.log(`Requests today: ${usage.requests_today}/${usage.monthly_quota}`);Error Handling
import {
Bloxchaser,
AuthenticationError,
RateLimitError,
APIError,
} from 'bloxchaser-sdk';
try {
const client = new Bloxchaser({ apiKey: 'invalid_key' });
await client.swaps.get();
} catch (error) {
if (error instanceof AuthenticationError) {
console.log('Invalid API key');
} else if (error instanceof RateLimitError) {
console.log(`Rate limited. Retry after ${error.retryAfter}s`);
} else if (error instanceof APIError) {
console.log(`API error: [${error.code}] ${error.message}`);
}
}Browser Usage
The SDK works in modern browsers. Use a bundler like Vite, webpack, or esbuild:
import { Bloxchaser } from 'bloxchaser-sdk';
// Works in browser!
const client = new Bloxchaser({ apiKey: 'bc_live_your_key' });Get an API Key
- Visit bloxchaser.com/signup
- Enter your email
- Save your API key (shown only once!)
Links
License
MIT
