Skip to article
relayOpen console
Make your first request
On this page

Start

Make your first request

Connect to Solana Mainnet with a Relay key and a single HTTP endpoint.

Create your API key

Sign in, choose a plan, and complete the SOL payment. After your first payment is finalized, open API keys and create a key for your application.

Use the eye icon in API Keys to reveal or hide a key, and the copy icon to copy it. For an older key, the eye icon lets you save your existing copy once to enable these controls. Lost older keys cannot be recovered; create a replacement instead. Revoked keys disappear from API Keys and connection selectors, while their usage history is preserved. All keys share your plan’s credits and rate limits.

Your RPC endpoint

Use this endpoint for supported Solana RPC and Digital Asset Standard requests. It connects to Solana Mainnet.

HTTPS endpoint
https://relayrpc.top/rpc

Set these variables in your local development environment or server. Replace the key placeholder with your Relay key.

Environment variables
export RELAY_RPC_URL="https://relayrpc.top/rpc"
export RELAY_API_KEY="YOUR_RELAY_KEY"

Send a request

getSlot returns a slot number at the requested commitment. It costs 1 credit when forwarded.

Read the latest finalized slot
curl "$RELAY_RPC_URL" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $RELAY_API_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"getSlot","params":[{"commitment":"finalized"}]}'

Inspect the JSON response: a successful call contains result; a failed call contains error. No request runs automatically from this documentation.

Use JavaScript

This server-side example reads the same environment variables and checks both HTTP and JSON-RPC errors.

Server-side fetch
const response = await fetch(process.env.RELAY_RPC_URL, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${process.env.RELAY_API_KEY}`,
  },
  body: JSON.stringify({
    jsonrpc: '2.0', id: 1, method: 'getSlot',
    params: [{ commitment: 'finalized' }],
  }),
});
const body = await response.json();
if (!response.ok || body.error) {
  throw new Error(body.error?.message ?? `HTTP ${response.status}`);
}
console.log(body.result);

Open Usage to inspect recorded requests and credits. If the request fails, use Errors and retries to choose the next step.

Search documentation

Find what you need

Search article headings, methods, and explanations.