Quick Setup

Get streaming Solana data in minutes with working code examples. Choose your approach based on your needs:

MethodBest ForPlan RequiredLatency
LaserStream gRPCMission-critical, backend servicesProfessional+Fastest
Enhanced WebSocketsAdvanced filtering, high-performance appsBusiness+Fast
Standard WebSocketsMost applications, existing Solana codeFree+Good
WebhooksServer notifications, event-driven appsFree+Variable

Option 1: Standard WebSockets

Perfect for most use cases and compatible with existing Solana WebSocket code.

const WebSocket = require('ws');

const ws = new WebSocket('wss://mainnet.helius-rpc.com?api-key=YOUR_API_KEY');

ws.on('open', () => {
  console.log('Connected to Helius');
  
  // Subscribe to account changes
  ws.send(JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "accountSubscribe",
    params: [
      "9PejEmViKHgUkVFWN57cNEZnFS4Qo6SzsLj5UPAXfDTF", // Replace with your account
      { encoding: "jsonParsed", commitment: "confirmed" }
    ]
  }));
});

ws.on('message', (data) => {
  const message = JSON.parse(data);
  if (message.method === 'accountNotification') {
    console.log('Account updated:', message.params.result.value);
  }
});

Replace YOUR_API_KEY with your key from dashboard.helius.dev

Standard WebSockets Guide

Complete reference with all subscription methods and examples

Option 2: Enhanced WebSockets

For applications needing advanced filtering and faster performance.

const WebSocket = require('ws');

const ws = new WebSocket('wss://atlas-mainnet.helius-rpc.com/?api-key=YOUR_API_KEY');

ws.on('open', () => {
  console.log('Enhanced WebSocket connected');
  
  // Subscribe to transactions involving specific accounts
  ws.send(JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "transactionSubscribe",
    params: [
      {
        accountInclude: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
        vote: false,
        failed: false
      },
      {
        commitment: "confirmed",
        encoding: "jsonParsed",
        transactionDetails: "full"
      }
    ]
  }));
  
  // Keep connection alive
  setInterval(() => ws.ping(), 30000);
});

ws.on('message', (data) => {
  const message = JSON.parse(data);
  console.log('Transaction:', message);
});

Enhanced WebSockets Guide

Learn advanced filtering and subscription options

Option 3: LaserStream gRPC

Most reliable option with historical replay and multi-node failover.

npm install helius-laserstream
import { subscribe, CommitmentLevel, LaserstreamConfig, SubscribeRequest } from 'helius-laserstream';

async function main() {
  const subscriptionRequest: SubscribeRequest = {
    transactions: {
      client: {
        accountInclude: ['TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'],
        accountExclude: [],
        accountRequired: [],
        vote: false,
        failed: false
      }
    },
    commitment: CommitmentLevel.CONFIRMED,
    accounts: {},
    slots: {},
    transactionsStatus: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    accountsDataSlice: [],
  };

  const config: LaserstreamConfig = {
    apiKey: 'YOUR_API_KEY',
    endpoint: 'https://laserstream-mainnet-ewr.helius-rpc.com',
  }

  await subscribe(config, subscriptionRequest, async (data) => {
    console.log(data);
  }, async (error) => {
    console.error(error);
  });
}

main().catch(console.error);

LaserStream Guide

Complete LaserStream documentation with historical replay

Option 4: Webhooks

For server-side applications that need event notifications.

# Create a webhook
curl -X POST "https://api.helius.xyz/v0/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookURL": "https://your-server.com/webhook",
    "transactionTypes": ["Any"],
    "accountAddresses": ["YOUR_ACCOUNT_ADDRESS"],
    "webhookType": "enhanced"
  }'
// Handle webhook events (Express.js example)
app.post('/webhook', (req, res) => {
  req.body.forEach(event => {
    console.log('Blockchain event:', event);
  });
  res.status(200).send('OK');
});

Webhooks Guide

Complete webhook setup and event handling

Common Use Cases

Monitor Token Transfers

// Subscribe to Token Program activity
method: "programSubscribe",
params: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", {...}]

Track NFT Sales

// Subscribe to Magic Eden program
method: "programSubscribe", 
params: ["M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K", {...}]

Watch Wallet Activity

// Monitor specific wallet
method: "accountSubscribe",
params: ["WALLET_ADDRESS", {...}]

Next Steps

Need help? Join our Discord or check support docs.