Real-time cryptocurrency price tracker with WebSocket support and historical data
- Real-time Prices - WebSocket streaming for live price updates
- REST API - Traditional REST endpoints for all operations
- Historical Data - OHLCV data with configurable timeframes
- Price Alerts - Set price alerts with webhook notifications
- Portfolio Tracking - Track holdings and calculate P&L
- Rate Limiting - Redis-based rate limiting per API key
- Caching - Intelligent caching to reduce API calls
GET /api/v1/prices/:symbol
GET /api/v1/prices?symbols=BTC,ETH,SOL
GET /api/v1/prices/:symbol/history?timeframe=1d&limit=30POST /api/v1/portfolio
GET /api/v1/portfolio/:id
PUT /api/v1/portfolio/:id/holdings
GET /api/v1/portfolio/:id/performancePOST /api/v1/alerts
GET /api/v1/alerts
DELETE /api/v1/alerts/:id// Connect to WebSocket
const ws = new WebSocket('wss://api.example.com/ws');
// Subscribe to price updates
ws.send(JSON.stringify({
type: 'subscribe',
channels: ['prices'],
symbols: ['BTC', 'ETH', 'SOL']
}));
// Receive updates
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data);
// { symbol: 'BTC', price: 45000, change24h: 2.5, ... }
};| Component | Technology |
|---|---|
| Runtime | Node.js 20, TypeScript |
| Framework | Fastify |
| Database | PostgreSQL, TimescaleDB |
| Cache | Redis |
| WebSocket | Socket.io |
| Queue | BullMQ |
| Docs | Swagger/OpenAPI |
# Clone the repo
git clone https://github.com/Zentex1337/crypto-tracker-api.git
cd crypto-tracker-api
# Install dependencies
pnpm install
# Set up environment
cp .env.example .env
# Start Redis and PostgreSQL
docker-compose up -d
# Run migrations
pnpm db:migrate
# Start development server
pnpm dev# Server
PORT=3000
NODE_ENV=development
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/crypto_tracker
# Redis
REDIS_URL=redis://localhost:6379
# External APIs
COINGECKO_API_KEY=your_key
COINMARKETCAP_API_KEY=your_key
# Auth
JWT_SECRET=your_secret
API_KEY_SALT=your_salt├── src/
│ ├── api/
│ │ ├── routes/
│ │ ├── controllers/
│ │ └── middleware/
│ ├── services/
│ │ ├── price.service.ts
│ │ ├── portfolio.service.ts
│ │ └── alert.service.ts
│ ├── websocket/
│ │ └── handlers/
│ ├── jobs/
│ │ └── price-updater.ts
│ ├── db/
│ │ ├── migrations/
│ │ └── models/
│ └── utils/
├── test/
└── docker-compose.yml
{
"success": true,
"data": {
"symbol": "BTC",
"price": 45000.50,
"change24h": 2.5,
"volume24h": 28000000000,
"marketCap": 880000000000,
"updatedAt": "2024-01-15T10:30:00Z"
}
}{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests, please try again later",
"retryAfter": 60
}
}| Plan | Requests/min | WebSocket Connections |
|---|---|---|
| Free | 30 | 1 |
| Pro | 300 | 5 |
| Enterprise | Unlimited | Unlimited |
- Average response time: <50ms
- WebSocket latency: <10ms
- Supports 10k+ concurrent connections
- 99.9% uptime SLA
- 500+ cryptocurrencies
- All major exchanges
- Real-time price aggregation
# Run all tests
pnpm test
# Run with coverage
pnpm test:coverage
# Run e2e tests
pnpm test:e2e# Build for production
pnpm build
# Start production server
pnpm start
# Or use Docker
docker build -t crypto-tracker-api .
docker run -p 3000:3000 crypto-tracker-apiContributions welcome! Please read CONTRIBUTING.md first.
MIT License - see LICENSE for details.
Built with ❤️ by Zentex
