dexscreener-api-client
v0.1.2
Published
TypeScript SDK for DexScreener API with full type support
Maintainers
Readme
dexscreener-api-client
TypeScript SDK for the DexScreener API.
Installation
npm install dexscreener-api-clientUsage
Basic Usage
import { DexScreenerClient } from 'dexscreener-api-client';
const client = new DexScreenerClient();
// Search for pairs
const results = await client.searchPairs('WETH USDC');
// Get token pairs
const pairs = await client.getTokenPairs('ethereum', '0x...');
// Get latest token profiles
const profiles = await client.getLatestTokenProfiles();Advanced Configuration
import { DexScreenerClient } from 'dexscreener-api-client';
const client = new DexScreenerClient({
// Custom API base URL (optional)
baseUrl: 'https://api.dexscreener.com',
// Request timeout in milliseconds (default: 10000)
timeout: 15000,
// Custom User-Agent header (default: 'dexscreener-api-client/{version}')
userAgent: 'MyApp/1.0',
// Custom headers to include with every request
headers: {
'X-Custom-Header': 'custom-value',
},
// Retry configuration for failed requests
retryConfig: {
maxRetries: 3, // Maximum number of retry attempts (default: 3)
retryDelay: 1000, // Base delay between retries in ms (default: 1000)
retryableStatusCodes: [408, 429, 500, 502, 503, 504], // HTTP codes to retry
},
});Configuration Options
baseUrl(optional): Custom API base URL. Default:'https://api.dexscreener.com'timeout(optional): Request timeout in milliseconds. Default:10000(10 seconds)userAgent(optional): Custom User-Agent string. Default:'dexscreener-api-client/{version}'headers(optional): Custom headers to include with every requestretryConfig(optional): Retry configuration for failed requestsmaxRetries: Maximum number of retry attempts. Default:3retryDelay: Base delay between retries in milliseconds (uses exponential backoff). Default:1000retryableStatusCodes: HTTP status codes that should trigger a retry. Default:[408, 429, 500, 502, 503, 504]
API Methods
Token Profiles & Orders
getLatestTokenProfiles(): Promise<TokenProfile[]>
getLatestCommunityTakeovers(): Promise<CommunityTakeover[]>
getLatestAdvertisements(): Promise<Advertisement[]>
getLatestTokenBoosts(): Promise<TokenBoost[]>
getTopTokenBoosts(): Promise<TokenBoost[]>
getTokenOrders(chainId: string, tokenAddress: string): Promise<Order[]>DEX Pairs
searchPairs(query: string): Promise<SearchResponse>
getPairsByChainAndAddress(chainId: string, pairAddresses: string | string[]): Promise<PairsResponse>
getTokenPairs(chainId: string, tokenAddress: string): Promise<Pair[]>
getPairsByTokenAddresses(tokenAddresses: string | string[]): Promise<PairsResponse>Rate Limits
- Token profile endpoints: 60 requests/minute
- DEX pair endpoints: 300 requests/minute
Types
All types are fully exported. Main types:
Pair- DEX trading pair dataTokenProfile- Token profile informationOrder- Token order dataTokenBoost- Token boost informationAdvertisement- Advertisement dataCommunityTakeover- Community takeover data
License
MIT
