A comprehensive trading platform backend API similar to Axiom.trade and GMGN.ai, built with Node.js, Express, TypeScript, and MongoDB. This platform provides real-time token analytics, wallet tracking, portfolio management, and trading insights for Solana and other blockchain networks.
- Token Analytics: Real-time price tracking, volume analysis, market cap, and holder statistics
- Wallet Tracking: Monitor wallet portfolios, trading history, and performance metrics
- Portfolio Management: Track holdings, calculate P&L, and analyze performance
- Transaction Monitoring: Real-time transaction tracking and analysis
- Market Overview: Aggregate market data, trending tokens, top gainers/losers
- Real-time Updates: WebSocket support for live price and wallet updates
- Search & Discovery: Advanced token search and filtering capabilities
- RESTful API with Express.js
- Real-time WebSocket communication via Socket.IO
- MongoDB for data persistence
- TypeScript for type safety
- Solana blockchain integration
- Token metadata fetching via Metaplex
- Comprehensive error handling and validation
- Node.js (v18 or higher)
- MongoDB (local or Atlas)
- Yarn package manager
- Solana RPC endpoint
-
Clone the repository
git clone <repository-url> cd cocos-plane-game
-
Install dependencies
yarn install
-
Configure environment variables
Create a
.envfile in the root directory:# Database Configuration DB_USERNAME=your_mongodb_username DB_PASSWORD=your_mongodb_password DB_HOST=your_mongodb_host DB_NAME=your_database_name # Server Configuration PORT=3000 # Solana Configuration RPC_ENDPOINT=https://api.mainnet-beta.solana.com RPC_WEBSOCKET_ENDPOINT=wss://api.mainnet-beta.solana.com # JWT Secret (if using authentication) JWT_SECRET=your_jwt_secret_key
-
Start the development server
yarn dev
Or for production:
yarn build yarn start
http://localhost:3000/api
Get Token Details
GET /api/tokens/:mintAddressReturns detailed information about a specific token.
Response:
{
"status": true,
"data": {
"mintAddress": "So11111111111111111111111111111111111111112",
"symbol": "SOL",
"name": "Solana",
"price": 150.25,
"priceChange24h": 5.50,
"priceChangePercent24h": 3.8,
"marketCap": 75000000000,
"volume24h": 5000000000,
"liquidity": 1000000000,
"holderCount": 5000000,
"image": "https://...",
"description": "..."
}
}Create/Update Token
POST /api/tokens
Content-Type: application/json
{
"mintAddress": "...",
"symbol": "TOKEN",
"name": "Token Name",
"price": 0.001,
"marketCap": 1000000,
"volume24h": 50000
}Get Token Price History
GET /api/tokens/:mintAddress/price-history?days=7Get Token Holders
GET /api/tokens/:mintAddress/holders?limit=100Get Token Transactions
GET /api/tokens/:mintAddress/transactions?limit=100&offset=0&type=buyGet Token Analytics
GET /api/analytics/token/:mintAddressReturns comprehensive analytics including recent transactions and top holders.
Get Trending Tokens
GET /api/analytics/trending?limit=50&sortBy=volume24hQuery parameters:
limit: Number of results (default: 50)sortBy: Sort field (volume24h, marketCap, priceChangePercent24h)
Get Wallet Analytics
GET /api/analytics/wallet/:addressReturns wallet portfolio, trading stats, and recent transactions.
Get Market Overview
GET /api/analytics/market/overviewReturns aggregate market statistics, top gainers, and top losers.
Search Tokens
GET /api/analytics/search?q=SOL&limit=20Get Wallet Portfolio
GET /api/wallets/portfolio/:addressUpdate Wallet Portfolio
POST /api/wallets/portfolio/:address
Content-Type: application/json
{
"holdings": [...],
"totalValue": 10000
}Get Wallet Transactions
GET /api/wallets/transactions/:address?limit=100&offset=0&type=buyTrack Wallet
POST /api/wallets/track
Content-Type: application/json
{
"address": "wallet_address",
"labels": ["whale", "trader"],
"notes": "Active trader"
}Get Tracked Wallets
GET /api/wallets/tracked?limit=50&offset=0Get Token List
POST /token/getListimport io from 'socket.io-client';
const socket = io('http://localhost:3000');
socket.on('connect', () => {
console.log('Connected to server');
});// Subscribe to token price updates
socket.emit('subscribe:token', 'mint_address_here');
// Receive token updates
socket.on('token:update', (data) => {
console.log('Token update:', data);
// {
// mintAddress: "...",
// price: 0.001,
// priceChange24h: 0.0001,
// priceChangePercent24h: 10.5,
// volume24h: 50000,
// marketCap: 1000000,
// liquidity: 500000
// }
});
// Unsubscribe
socket.emit('unsubscribe:token', 'mint_address_here');// Subscribe to wallet updates
socket.emit('subscribe:wallet', 'wallet_address_here');
// Receive wallet updates
socket.on('wallet:update', (data) => {
console.log('Wallet update:', data);
});
// Unsubscribe
socket.emit('unsubscribe:wallet', 'wallet_address_here');socket.on('connectionUpdated', (count) => {
console.log('Active connections:', count);
});mintAddress: Unique token identifiersymbol,name: Token informationprice,priceChange24h,priceChangePercent24h: Price datamarketCap,volume24h,liquidity: Market metricsholderCount,topHolders: Holder informationimage,description: MetadataisVerified,riskScore: Analytics flags
address: Wallet addresstotalValue,totalValueChange24h: Portfolio valuetokens: Array of token holdingstotalTrades,totalVolume,winRate: Trading statsisWhale: Whale flaglabels,notes: Custom labels
signature: Transaction signaturewallet,tokenMint: Participantstype: buy, sell, transfer, swapamount,amountUSD,price: Transaction detailsplatform,dex: Trading platformstatus: success, failed, pending
walletAddress: Associated walletholdings: Array of token holdings with valuestotalValue,totalValueChange24h: Portfolio metricstotalProfit,totalProfitPercent: Performance metrics
cocos-plane-game/
βββ api/ # API service functions
βββ config/ # Configuration files
βββ model/ # MongoDB models
β βββ TokenModel/
β βββ WalletModel/
β βββ TransactionModel/
β βββ PortfolioModel/
β βββ UserModel/
βββ routes/ # Express routes
β βββ TokenRoute/
β βββ AnalyticsRoute/
β βββ WalletRoute/
β βββ CoinRoute/
βββ socket/ # WebSocket server
βββ utils/ # Utility functions
βββ index.ts # Main server file
βββ package.json
βββ tsconfig.json
yarn dev: Start development server with hot reloadyarn start: Start production serveryarn build: Build TypeScript to JavaScriptyarn ts.check: Type check without buildingyarn test: Run tests
- TypeScript strict mode enabled
- ESLint for code quality
- Pre-commit hooks for type checking
- Use environment variables for sensitive data
- Implement rate limiting for API endpoints
- Add authentication/authorization for protected routes
- Validate and sanitize all user inputs
- Use HTTPS in production
- Implement CORS policies appropriately
- Set up MongoDB Atlas or self-hosted MongoDB
- Configure environment variables
- Set up Solana RPC endpoint (consider using premium RPC for production)
- Configure reverse proxy (nginx) if needed
- Set
NODE_ENV=production - Use secure MongoDB connection string
- Enable HTTPS
- Set up monitoring and logging
- Configure rate limiting
- Set up backup strategy for MongoDB
- Use process manager (PM2, systemd)
- Set up error tracking (Sentry, etc.)
- Use MongoDB indexes for frequently queried fields
- Implement caching for frequently accessed data (Redis)
- Use connection pooling for database connections
- Optimize WebSocket message broadcasting
- Consider using CDN for static assets
- Implement pagination for large datasets
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
- Inspired by Axiom.trade and GMGN.ai
- Built with Solana Web3.js
- Uses Metaplex for NFT metadata
For issues, questions, or contributions, please open an issue on the GitHub repository.
Built with β€οΈ for the Solana trading community