Skip to content

API integration

EVM and Bitcoin RPC endpoints, JSON-RPC request envelopes, batching, WebSocket, and error contracts.

Use this reference to configure endpoints, shape requests, match batch responses, and handle errors. GraphOps RPC exposes Ethereum-compatible JSON-RPC over HTTPS and WebSocket, plus Bitcoin JSON-RPC over HTTPS. For individual methods, see Supported methods.

Endpoint patterns

Reference

https://rpc.graphops.xyz/v1/evm/<chainId>
wss://rpc.graphops.xyz/v1/evm/<chainId>

Endpoint preview

Replace placeholders with your identifier and API key before making requests.

Use the concrete URL for your target chain in application configuration or client setup.

See Supported networks for current query endpoints and archive coverage.

Bitcoin endpoints

Bitcoin RPC uses HTTPS and a network name instead of an EVM chain ID. The endpoint route is:

Reference

/v1/bitcoin/<network>[/API_KEY]

For example, an authenticated Bitcoin mainnet request looks like this:

Prerequisites

  1. Set GRAPHOPS_API_KEY to your GraphOps API key.

curl --fail-with-body --silent --show-error "https://rpc.graphops.xyz/v1/bitcoin/mainnet" \
  -H "Authorization: Bearer ${GRAPHOPS_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getblockchaininfo",
    "params": []
  }'

Clients that cannot attach headers can use the route-token form instead:

Reference

https://rpc.graphops.xyz/v1/bitcoin/mainnet/<GRAPHOPS_API_KEY>

Authentication

Authenticate with an organization-scoped API key. RPC supports header authentication and route-token authentication. See Authentication for key creation, rotation, WebSocket connections, and secret handling.

Request envelope

Every EVM and Bitcoin JSON-RPC call uses the standard request envelope. Method names and parameter formats are network-specific; the examples in this section use EVM methods.

FieldTypeRequiredNotes
jsonrpcstringYesMust be "2.0".
idstring, number, or nullRequired for request/response callsUse a stable value so clients can match responses, especially in batches.
methodstringYesStandard Ethereum-compatible method name, such as eth_blockNumber.
paramsarray or objectMethod-specificEthereum JSON-RPC methods usually use positional arrays.

JSON

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_blockNumber",
  "params": []
}

Output

{  "jsonrpc": "2.0",JSON-RPC version  "id": 1,Matches the id you sent  "result": "0x1908d5f"Latest block in decimal: 26,250,591}

HTTPS requests

HTTPS requests use POST with Content-Type: application/json. The examples below use Ethereum mainnet.

Prerequisites

  1. Set GRAPHOPS_API_KEY to your GraphOps API key.

curl --fail-with-body --silent --show-error "https://rpc.graphops.xyz/v1/evm/1" \
  -H "Authorization: Bearer ${GRAPHOPS_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_blockNumber",
    "params": []
  }'

Output

{  "jsonrpc": "2.0",JSON-RPC version  "id": 1,Matches the id you sent  "result": "0x1908d5f"Latest block in decimal: 26,250,591}

Batch requests

Batch requests are supported. Use them when several independent calls can share one HTTP round trip. Do not use a batch when later calls depend on earlier results.

JSON

[
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_blockNumber",
    "params": []
  },
  {
    "jsonrpc": "2.0",
    "id": 2,
    "method": "eth_chainId",
    "params": []
  },
  {
    "jsonrpc": "2.0",
    "id": 3,
    "method": "eth_getBalance",
    "params": ["0xnot-an-address", "latest"]
  }
]

Output

[  {    "jsonrpc": "2.0",    "id": 1,    "result": "0x1908d62"eth_blockNumber in decimal: 26,250,594  },  {    "jsonrpc": "2.0",    "id": 2,    "result": "0x1"Ethereum mainnet chain ID: 1  },  {    "jsonrpc": "2.0",    "id": 3,    "error": {      "code": -32602,Only this call failed: invalid parameters      "message": "Invalid params",      "data": "invalid string length at line 1 column 18"    }  }]

In the output, the third call fails because its address is invalid; the other two succeed.

Match responses by id; do not rely on response ordering. Retry only the failed items that are retryable, as a smaller batch or as single requests.

WebSocket connections

Use WebSocket endpoints for subscriptions and long-lived event streams. Route-token authentication works with WebSocket clients that cannot attach custom headers during the handshake.

Prerequisites

  1. Install Node.js.

  2. Install tsx and ws.

    npm install tsx ws
  3. Set GRAPHOPS_API_KEY to your GraphOps API key.

TypeScript

import WebSocket from "ws";

// Route-token URL: the API key is the final path segment.
const socket = new WebSocket(
  `wss://rpc.graphops.xyz/v1/evm/1/${process.env.GRAPHOPS_API_KEY}`,
);

socket.once("error", (error) => { throw error; });
socket.once("open", () => {
  console.log(JSON.stringify({ connected: true }));
  socket.close();
});

See Authentication for header authentication, route-token authentication, and security guidance.

WebSocket subscriptions

GraphOps supports standard Ethereum subscription flows over WebSocket:

SubscriptionUse it for
newHeadsReceive new block headers.
logsReceive logs matching an address and topic filter.
newPendingTransactionsReceive pending transaction hashes when available for the network.
syncingReceive node sync status updates.

Persist the last processed block or log cursor in your application. If a WebSocket disconnects, use WebSocket subscriptions for recovery patterns.

Error responses

JSON-RPC errors use the standard error object in place of result:

JSON

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getBalance",
  "params": [
    "invalid-address",
    "latest"
  ]
}

Output

{  "jsonrpc": "2.0",  "id": 1,The call that failed  "error": {Present instead of result    "code": -32602,Invalid params; see the table below    "message": "odd number of digits"Points at the first parameter  }}

Common error classes:

Code or statusMeaningTypical response
400Malformed HTTP request or invalid JSON body.Fix request encoding.
401Missing or invalid API key.Check header or route-token authentication.
403Organization is not entitled to the endpoint or feature.Check plan and network access.
429Organization exceeded rate or concurrency limits.Back off and reduce concurrency.
-32700JSON parse error.Send valid JSON.
-32600Invalid JSON-RPC request envelope.Include jsonrpc, method, and valid id when needed.
-32601Method not found.Check method spelling, transport, and network support.
-32602Invalid params.Check parameter order, hex encoding, and block tag.
-32603Internal JSON-RPC error.Retry if transient; contact support if persistent.
-32000 to -32099Server or EVM execution error.Inspect the message and method-specific context.

Next steps