Package Exports
- gdex.pro-sdk
- gdex.pro-sdk/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gdex.pro-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
GDEX SDK
A TypeScript SDK for interacting with GDEX API endpoints, providing comprehensive access to trading, analytics, and real-time data.
Features
- 🚀 TypeScript Support: Full type safety and IntelliSense
- 🌐 REST API Client: Complete access to all GDEX endpoints
- 📡 WebSocket Client: Real-time data streaming
- 🔧 Crypto Utilities: Address validation, formatting, and wallet operations
- 📊 Trading Operations: Place orders, manage positions, get market data
- 📈 Analytics: Market insights, trending tokens, and statistics
- 🔌 Multi-network: Support for Ethereum, BSC, Polygon, and more
Installation
npm install gdex-sdkQuick Start
import { createSDK } from 'gdex-sdk';
// Create SDK instance
const sdk = createSDK('https://api.gdex.io', 'ethereum', {
wsURL: 'wss://ws.gdex.io',
apiKey: 'your-api-key', // Optional for public endpoints
});
// Get trending tokens
const trending = await sdk.tokens.getTokens({
page: 1,
limit: 10,
sortBy: 'marketCap',
});
console.log('Trending tokens:', trending.items);API Reference
Token Operations
// Get token details
const token = await sdk.tokens.getToken('0x...');
// Get token statistics
const stats = await sdk.tokens.getTokenStats('0x...');
// Search tokens
const results = await sdk.tokens.searchTokens('USDC');
// Get price history
const history = await sdk.tokens.getPriceHistory('0x...', '1h', 100);Trading Operations
// Get user positions (requires authentication)
const positions = await sdk.trading.getPositions();
// Get order book
const orderbook = await sdk.trading.getOrderBook('0x...', 20);
// Place an order (requires authentication)
const order = await sdk.trading.placeOrder({
tokenAddress: '0x...',
side: 'BUY',
type: 'LIMIT',
amount: '100',
price: '1.50',
});Analytics
// Get trending tokens
const trending = await sdk.analytics.getTrendingTokens(50);
// Get top movers
const gainers = await sdk.analytics.getTopMovers('gainers', '24h');
// Get market overview
const overview = await sdk.analytics.getMarketOverview();Real-time Data (WebSocket)
// Connect to WebSocket
await sdk.connectWebSocket();
const wsClient = sdk.getWebSocketClient();
// Subscribe to real-time data
wsClient.subscribe({ channel: 'trades', symbol: 'ETH/USDC' });
wsClient.subscribe({ channel: 'orderbook', symbol: 'BTC/USDC' });
// Listen for events
wsClient.on('trade', (trade) => {
console.log('New trade:', trade);
});
wsClient.on('orderbook', (orderbook) => {
console.log('Order book update:', orderbook);
});Crypto Utilities
import { CryptoUtils } from 'gdex-sdk';
// Address operations
const isValid = CryptoUtils.isValidAddress('0x...');
const checksum = CryptoUtils.toChecksumAddress('0x...');
const shortened = CryptoUtils.shortenAddress('0x...');
// Amount formatting
const formatted = CryptoUtils.formatTokenAmount('1000000000000000000', 18);
const currency = CryptoUtils.formatCurrency(1234567.89);
const percentage = CryptoUtils.formatPercentage(25.5);
// Wallet operations
const wallet = CryptoUtils.generateRandomWallet();
const fromPrivateKey = CryptoUtils.createWalletFromPrivateKey('0x...');Configuration
import { GDEXSDK, NETWORKS } from 'gdex-sdk';
const sdk = new GDEXSDK({
baseURL: 'https://api.gdex.io',
wsURL: 'wss://ws.gdex.io',
apiKey: 'your-api-key',
timeout: 30000,
network: NETWORKS.ethereum, // or 'ethereum', 'bsc', 'polygon'
});Supported Networks
- Ethereum (ethereum)
- Binance Smart Chain (bsc)
- Polygon (polygon)
Error Handling
try {
const token = await sdk.tokens.getToken('invalid-address');
} catch (error) {
if (error.code === '404') {
console.log('Token not found');
} else if (error.code === 'NETWORK_ERROR') {
console.log('Network issue');
}
console.error('Error:', error.message);
}Examples
Check out the examples/ directory for complete usage examples:
basic-usage.ts- Basic API operationswebsocket-example.ts- Real-time data streamingtrading-example.ts- Trading operationscrypto-utils.ts- Utility functions
Development
# Clone the repository
git clone https://github.com/your-org/gdex-sdk.git
cd gdex-sdk
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Watch mode for development
npm run devLicense
MIT
Support
For questions and support, please visit our documentation or Discord server.