A simple, secure WebSocket proxy server that forwards Algorand algod API requests. Keeps your algod API token secure on the server while providing real-time access to Algorand data.
- Secure: API tokens stay server-side, never exposed to clients
- Real-time: WebSocket connections for low-latency data access
- CORS-free: Bypasses browser CORS restrictions
- Simple: Minimal configuration, easy to deploy
- Production-ready: Error handling, authentication, and graceful shutdown
-
Install dependencies:
npm install ws dotenv
-
Configure environment:
cp .env.template .env # Edit .env with your settings -
Run the server:
node websocket-server.js
| Variable | Description | Default |
|---|---|---|
ALGOD_TOKEN |
Your algod API token | required |
ALGOD_SERVER |
Algod server URL | http://localhost |
ALGOD_PORT |
Algod port | 8080 |
WS_PORT |
WebSocket server port | 8081 |
WS_AUTH_TOKEN |
Client authentication token | required |
Connect to WebSocket:
const ws = new WebSocket('ws://your-server:8081/algod?token=your_auth_token')Send requests:
ws.send(JSON.stringify({
endpoint: '/v2/transactions/pending',
method: 'GET'
}))Receive responses:
ws.onmessage = (event) => {
const response = JSON.parse(event.data)
console.log(response.data) // Algod response
}- Real-time mempool monitoring
- DeFi applications needing live data
- Analytics dashboards
- Any app requiring secure algod access
- Only
/v2/endpoints allowed - Token-based client authentication
- API tokens never exposed to clients
- Request validation and error handling
MIT