API Reference

Complete reference for Prism's JSON-RPC API, HTTP endpoints, and custom extensions.

Table of Contents


HTTP Endpoints

Prism exposes the following HTTP endpoints:

Endpoint
Method
Description
Content-Type

/

POST

Single or batch JSON-RPC request

application/json

/health

GET

Health check and status information

application/json

/metrics

GET

Prometheus metrics

text/plain

Note: Batch requests are sent to / as an array, not to a separate /batch endpoint.

/ - Single JSON-RPC Request

Send a single JSON-RPC 2.0 request.

Request:

Response:

/ - Batch Requests

Send multiple JSON-RPC requests in a single HTTP call by passing an array:

Request:

Response:

/health - Health Check

Get system health and upstream status.

Request:

Response:

/metrics - Prometheus Metrics

Prometheus-compatible metrics endpoint.

Request:

Response:


Supported RPC Methods

Prism supports the following Ethereum JSON-RPC methods:

Cached Methods

These methods use Prism's caching system for improved performance:

Method
Cache Type
Description

eth_getBlockByHash

Block Cache

Get block by hash (with or without transactions)

eth_getBlockByNumber

Block Cache

Get block by number (with or without transactions)

eth_getLogs

Log Cache

Get event logs with partial-range support

eth_getTransactionByHash

Transaction Cache

Get transaction by hash

eth_getTransactionReceipt

Transaction Cache

Get transaction receipt

Forwarded Methods (No Caching)

These methods are forwarded directly to upstream providers:

Method
Description

net_version

Get network ID

eth_blockNumber

Get latest block number

eth_chainId

Get chain ID

eth_gasPrice

Get current gas price

eth_getBalance

Get account balance

eth_getCode

Get contract code


Request Format

All requests must conform to JSON-RPC 2.0 specification.

Structure

Field
Type
Required
Description

jsonrpc

string

Yes

Must be "2.0"

method

string

Yes

RPC method name (e.g., "eth_blockNumber")

params

array

No

Method parameters (can be empty [] or omitted)

id

number/string

Yes

Request identifier, echoed in response

Method-Specific Parameters

eth_getBlockByNumber

eth_getBlockByHash

eth_getLogs

eth_getTransactionByHash

eth_getTransactionReceipt


Response Format

All responses conform to JSON-RPC 2.0 specification.

Success Response

Field
Type
Description

jsonrpc

string

Always "2.0"

result

any

Method-specific result data

id

number/string

Request ID echoed from request

Error Response

Field
Type
Description

jsonrpc

string

Always "2.0"

error.code

integer

Error code (see Error Codes)

error.message

string

Human-readable error message

error.data

any

Optional additional error data

id

number/string/null

Request ID or null if ID couldn't be determined


Custom Headers

Prism adds custom headers to responses for observability and debugging.

X-Cache-Status

Indicates how the request was served from cache or upstream.

Values:

Value
Meaning

MISS

Request served entirely from upstream (not in cache)

FULL

Complete cache hit, no upstream call needed

PARTIAL

Some data from cache, rest fetched from upstream

EMPTY

Cached empty result (e.g., no logs found in range)

PARTIAL_WITH_FAILURES

Partial cache hit with some upstream failures

Example:

Request Headers

X-API-Key (Authentication)

Include your API key when authentication is enabled.

Alternatively, use query parameter:

Standard Headers


Batch Requests

Send multiple requests in a single HTTP call to reduce latency.

Format

Array of JSON-RPC request objects:

Response

Array of JSON-RPC response objects (order may not match request order):

Benefits

  • Reduced HTTP overhead: Single connection for multiple requests

  • Lower latency: Batch processing reduces round-trip time

  • Atomic execution: All requests processed together

Limitations

  • Maximum batch size: Configured by max_concurrent_requests

  • Each request is still processed independently (no transaction semantics)

  • Cache status header applies to batch as a whole


Error Codes

Prism follows JSON-RPC 2.0 error codes with some extensions.

Standard JSON-RPC Errors

Code
Message
Description

-32700

Parse error

Invalid JSON received

-32600

Invalid Request

Request object is malformed

-32601

Method not found

Method does not exist or is not supported

-32602

Invalid params

Invalid method parameters

-32603

Internal error

Internal server error

Ethereum-Specific Errors

Code
Message
Description

-32000

Server error

Generic server error

-32001

Resource not found

Requested resource does not exist

-32002

Resource unavailable

Resource temporarily unavailable

-32003

Transaction rejected

Transaction would not be accepted

-32004

Method not supported

Method is not implemented

-32005

Limit exceeded

Request exceeds defined limit

Prism-Specific Errors

Code
Message
Description

-32050

No healthy upstreams

All upstream providers are unavailable

-32051

Circuit breaker open

Upstream circuit breaker is open

-32052

Consensus failure

Upstreams disagree on response (consensus mode)

-32053

Rate limit exceeded

Request rate limit exceeded

-32054

Authentication failed

Invalid or missing API key

-32055

Method not allowed

API key does not have permission for this method

Upstream Provider Errors

Errors from upstream providers are passed through with their original error codes.

Example Upstream Error:


Code Examples

JavaScript / Node.js

Python

cURL

Rust (using reqwest)

Go


Web3 Library Integration

Prism can be used as a drop-in replacement for any Ethereum RPC endpoint.

ethers.js

web3.py

web3.js


Next: Learn about Caching or Routing Strategies.

Last updated