0.2.0 • Published 10 months ago
@cfxdevkit/geckoterminal v0.2.0
@cfxdevkit/geckoterminal
A TypeScript library for interacting with the GeckoTerminal API, providing easy access to DEX pools, tokens, and trading data on the Conflux Network and other chains.
Features
- 🚀 Full TypeScript support with comprehensive type definitions
- 📊 Access to GeckoTerminal's DEX pools and token data
- 💱 Real-time trading information and price data
- 📈 Built-in data formatting and utility functions
- 🔍 Detailed error handling and logging
- 📝 Well-documented API methods
- ⚡ Modern ES6+ syntax
Installation
npm install @cfxdevkit/geckoterminalQuick Start
import { GeckoTerminal } from '@cfxdevkit/geckoterminal';
const client = new GeckoTerminal();
// Get all networks
const networks = await client.getNetworks();
// Get DEXes for Conflux network
const dexes = await client.getNetworkDexes('cfx');
// Get top pools for Swappi on Conflux
const pools = await client.getTopPools('cfx', 'swappi');Examples
Network and DEX Information
const client = new GeckoTerminal();
// Get all supported networks
const networks = await client.getNetworks();
// Get DEXes for a specific network
const dexes = await client.getNetworkDexes('cfx');Pool Information
// Get top pools for a specific DEX
const topPools = await client.getTopPools('cfx', 'swappi');
// Get trending pools
const trendingPools = await client.getTrendingPools('cfx', '24h');
// Get new pools
const newPools = await client.getNewPools('cfx');
// Get specific pool information
const poolInfo = await client.getPoolInfo('cfx', 'pool_address');
// Get pool OHLCV data
const ohlcv = await client.getPoolOHLCV('cfx', 'pool_address', 'hour', {
limit: '3'
});Token Information
// Get token information
const tokenInfo = await client.getTokenInfo('cfx', 'token_address');
// Get pools for a specific token
const tokenPools = await client.getTokenPools('cfx', 'token_address');
// Get multiple token information
const multiTokenInfo = await client.getMultiTokenInfo('cfx', ['token1', 'token2']);
// Get simple token prices
const tokenPrices = await client.getSimpleTokenPrices('cfx', ['token1', 'token2'], true, true);Search Functionality
// Search for pools
const searchResults = await client.searchPools('WETH', 'cfx');Formatting Utilities
The library includes various formatting utilities for data presentation:
import { formatUtils } from '@cfxdevkit/geckoterminal';
// Format currency
formatUtils.currency(1234.5678); // "$1,234.57"
formatUtils.compactCurrency(1234567); // "$1.23M"
// Format percentages
formatUtils.percentage(12.345); // "12.35%"
formatUtils.changePercent(-12.345); // "-12.35%"
// Format dates
formatUtils.date(1612137600); // "2021-02-01 00:00:00"
formatUtils.monthYear(new Date("2024-02-15")); // "February 2024"
// Classify volatility
formatUtils.volatility(0.75); // "High"API Reference
Networks and DEXes
Get Networks
const networks = await client.getNetworks();Get Network DEXes
const dexes = await client.getNetworkDexes('cfx');Pools
Get Top Pools
const pools = await client.getTopPools('cfx', 'swappi');Get Trending Pools
const trending = await client.getTrendingPools('cfx', '24h');Get Pool Information
const info = await client.getPoolInfo('cfx', 'pool_address');Tokens
Get Token Information
const token = await client.getTokenInfo('cfx', 'token_address');Get Token Prices
const prices = await client.getSimpleTokenPrices('cfx', ['token_address']);Development
Prerequisites
- Node.js >= 16.0.0
- npm
Setup
- Clone the repository:
git clone https://github.com/cfxdevkit/geckoterminal.git
cd geckoterminal- Install dependencies:
npm installAvailable Scripts
npm run build- Build the librarynpm run test- Run testsnpm run test:coverage- Run tests with coveragenpm run lint- Lint the codenpm run format- Format the codenpm run example- Run example usage script
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Links
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- GeckoTerminal for providing the API