The Nolimitnodes API returns standard JSON-RPC 2.0 error responses. This page documents common error codes and recommended handling strategies.

Error Response Format

jsonrpc
string
Always "2.0".
error
object
id
integer
The request ID that caused the error.

Example Error Response

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32600,
    "message": "Invalid request"
  },
  "id": 1
}

JSON-RPC Error Codes

CodeMessageDescription
-32700Parse errorInvalid JSON in the request body.
-32600Invalid requestThe request object is not a valid JSON-RPC 2.0 request.
-32601Method not foundThe requested RPC method does not exist.
-32602Invalid paramsInvalid method parameters.
-32603Internal errorAn internal server error occurred.

HTTP Status Codes

CodeMeaningAction
200SuccessRequest processed successfully.
400Bad RequestCheck your request format and parameters.
401UnauthorizedInvalid or missing API key.
429Too Many RequestsRate limit exceeded. Implement exponential backoff.
500Internal Server ErrorRetry after a brief delay.
503Service UnavailableThe node is temporarily unavailable. Retry later.

Handling Errors

async function safeRpcCall(endpoint, method, params = []) {
  const response = await fetch(endpoint, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  });

  if (response.status === 429) {
    throw new Error("Rate limited — retry with backoff");
  }

  if (response.status === 401) {
    throw new Error("Invalid API key");
  }

  const data = await response.json();

  if (data.error) {
    throw new Error(`RPC Error ${data.error.code}: ${data.error.message}`);
  }

  return data.result;
}

WebSocket Error Handling

For WebSocket connections, handle disconnections gracefully with automatic reconnection:
function connectWithReconnect(url, maxRetries = 5) {
  let retries = 0;

  function connect() {
    const ws = new WebSocket(url);

    ws.on("open", () => {
      retries = 0; // Reset on successful connection
    });

    ws.on("close", () => {
      if (retries < maxRetries) {
        const delay = Math.pow(2, retries) * 1000;
        retries++;
        setTimeout(connect, delay);
      }
    });

    ws.on("error", (err) => {
      console.error("WebSocket error:", err.message);
      ws.close();
    });

    return ws;
  }

  return connect();
}