WebSocket
Real-time streaming for account changes, transaction logs, and slot updates.
Endpoint:
Auth:
Min balance: 100 credits to connect. Auto-disconnect below 10 credits.
wss://rpc.nodius.xyz/wsAuth:
Authorization: Bearer TOKEN header or Sec-WebSocket-Protocol: auth.TOKENMin balance: 100 credits to connect. Auto-disconnect below 10 credits.
Connecting
TypeScript
Raw WebSocket
import { NodiusClient } from "@nodius/sdk";
const rpc = new NodiusClient({
endpoint: "https://rpc.nodius.xyz",
keypair,
auth: "session",
});
const subId = await rpc.ws.accountSubscribe(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{ encoding: "base64", commitment: "confirmed" },
(notification) => console.log(notification)
);
const ws = new WebSocket("wss://rpc.nodius.xyz/ws", {
headers: { Authorization: "Bearer YOUR_TOKEN" }
});
// Or for browser clients:
const ws = new WebSocket(
"wss://rpc.nodius.xyz/ws",
["auth.YOUR_TOKEN"]
);
Subscription Methods
| Method | Description | Tier |
|---|---|---|
accountSubscribe | Monitor specific account data changes | All |
logsSubscribe | Transaction logs (all or filtered by pubkey) | All |
programSubscribe | All accounts owned by a program | All |
signatureSubscribe | Transaction confirmation (auto-unsubscribes) | All |
slotSubscribe | Slot number updates (~400ms) | All |
rootSubscribe | Finalized root slot updates | All |
blockSubscribe | Full block data streaming | Performance |
Example: Subscribe to Account Changes
{
"jsonrpc": "2.0",
"id": 1,
"method": "accountSubscribe",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{ "encoding": "base64", "commitment": "confirmed" }
]
}
// Response: { "jsonrpc": "2.0", "result": 42, "id": 1 }
// 42 is your subscription ID — use it to unsubscribe
Example: Filter Logs by Program
{
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{ "mentions": ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"] },
{ "commitment": "confirmed" }
]
}
Credit Costs
| Action | Credits |
|---|---|
| Subscribe | 5 per subscription |
| Notification received | 1 per notification |
| Unsubscribe / Connect | 0 |
Estimated Hourly Costs
| Subscription | ~Credits/Hour |
|---|---|
slotSubscribe | ~9,000 |
signatureSubscribe | ~6 (one-time) |
logsSubscribe (all) | 10,000+ |
programSubscribe (Token Program) | 100,000+ |
Subscription Limits
| Tier | Max Subscriptions |
|---|---|
| Standard | 10 concurrent |
| Performance | 50 concurrent |
Exceeding the limit returns: {"error":{"code":-32000,"message":"Subscription limit reached (10/10)"}}
Close Codes
| Code | Reason | Description |
|---|---|---|
| 1008 | policy_violation | Invalid or expired token |
| 4001 | auth_failed | Authentication failed |
| 4002 | insufficient_credits | Balance dropped below 10 credits |
| 4003 | rate_limited | Message frequency too high |
Best Practices
- Always unsubscribe explicitly — don't rely on socket closure for cleanup
- Filter your logs — avoid
logsSubscribe("all")to prevent massive credit drain - Choose commitment wisely —
finalizedreduces notification volume and cost;processedgives highest speed at highest cost - Monitor your balance — high-frequency subscriptions like
programSubscribeon popular programs can drain thousands of credits per hour - Handle reconnection — the SDK auto-reconnects with exponential backoff and restores subscriptions