> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Edge Nodes

> Connect to a Codex edge node for the fastest Processed (unconfirmed) events and bars on Solana, Base, and Robinhood.

Edge nodes are separate Codex WebSocket endpoints that deliver `Processed` (unconfirmed) events and bars faster than `wss://graph.codex.io/graphql`. Each one runs close to where its networks produce blocks, so trades reach you sooner wherever your app is hosted.

> [!NOTE]
>
> Edge nodes are in beta. They use the same API key, the same `graphql-transport-ws` protocol, and the same billing as the main endpoint. WebSockets require a Growth or Enterprise plan. [Learn more](https://dashboard.codex.io/dashboard/billing?utm_source=codex\&utm_medium=docs\&utm_campaign=concepts-edge-endpoints).

## Which edge node to use

Pick the edge node by **network**, not by where your servers are. For example, use the Solana edge node for Solana data even if your app runs in the US or Asia.

| Network | Edge node endpoint |
| - | - |
| Solana (`1399811149`) | `wss://fra.edge.codex.io/graphql` |
| Base (`8453`) | `wss://iad.edge.codex.io/graphql` |
| Robinhood (`4663`) | `wss://iad.edge.codex.io/graphql` |

If you send a subscription for a network to the wrong edge node, it still works, but it is relayed from the main API and gets no speed benefit.

## What the edge nodes serve

The speed benefit applies to these four subscriptions when `commitmentLevel` includes `Processed`, for a single supported network:

* [`onEventsCreated`](https://docs.codex.io/api-reference/subscriptions/oneventscreated)
* [`onTokenEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokeneventscreated)
* [`onBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onbarsupdated) (set `quoteToken`)
* [`onTokenBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/ontokenbarsupdated)

Everything else follows these rules:

* **Other subscriptions** (prices, holders, stats, balances, launchpad events, and so on) are accepted, but they are relayed from the main API. That adds a hop, so they arrive slightly **later** than on `graph.codex.io`. Keep them on the main endpoint.
* **`Confirmed` data** always comes from the main API. Leaving out `commitmentLevel` means `Confirmed`, the same as on the main endpoint.
* **Queries and mutations** are not accepted. Send them to `https://graph.codex.io/graphql`.

> [!TIP]
>
> If you need both Processed and Confirmed updates, use one subscription on the edge node with `commitmentLevel: [Processed, Confirmed]`, not separate Processed and Confirmed subscriptions. The edge node serves the Processed update itself, gets the Confirmed update from the main API, and dedupes them on the server. Each event arrives at most once per stage, and you are less likely to receive updates out of order.

## Connecting

### SDK

In [`@codex-data/sdk`](https://docs.codex.io/sdk) 2.4.13 or later, pass `{ useEdge: true }` as the options argument. The SDK picks the right edge node for Solana and Robinhood.

```typescript theme={null}
import { Codex, EventCommitmentLevel } from "@codex-data/sdk";

const sdk = new Codex(process.env.CODEX_API_KEY!);

sdk.subscriptions.onTokenEventsCreated(
  {
    input: {
      tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      networkId: 1399811149,
    },
    commitmentLevel: [EventCommitmentLevel.Processed, EventCommitmentLevel.Confirmed],
  },
  {
    next: (result) => console.log(result.data),
    error: console.error,
    complete: () => {},
  },
  { useEdge: true },
);
```

`useEdge` is experimental. It only accepts the four subscriptions above, with `Processed` in `commitmentLevel`, on Solana or Robinhood. Base is not supported in the SDK yet, so connect to the Base edge node directly as shown below.

### Direct WebSocket

Connect the same way you connect to the main endpoint (see [Subscriptions](https://docs.codex.io/concepts/subscriptions.md#how-it-works)), with the edge node endpoint:

```typescript graphql-ws theme={null}
import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://fra.edge.codex.io/graphql",
  connectionParams: {
    Authorization: apiKey,
  },
});

client.subscribe(
  {
    query: `
      subscription($tokenAddress: String!, $networkId: Int!) {
        onTokenEventsCreated(
          input: { tokenAddress: $tokenAddress, networkId: $networkId }
          commitmentLevel: [Processed, Confirmed]
        ) {
          id
          events {
            eventType
            timestamp
            transactionHash
            maker
          }
        }
      }
    `,
    variables: {
      tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      networkId: 1399811149,
    },
  },
  {
    next: (data) => console.log(data),
    error: (error) => console.error(error),
    complete: () => console.log("complete"),
  },
);
```

## Good to know

* **Processed data is unconfirmed.** A small number of events can be dropped or reorged out before confirmation. Use `Confirmed` from the main API when you need settled data.
* **Billing is the same.** Each delivered message costs the same as it would on `graph.codex.io` and counts against the same plan. Edge connections count toward your account's connection limit.
* **Regional feed errors.** If an edge node loses its feed for a network, the affected subscriptions end with an `EDGE_NETWORK_UNAVAILABLE` error. Other subscriptions on the connection keep running. Resubscribe, or fall back to `graph.codex.io` until it recovers.
* **Token bars.** On edge nodes, `onTokenBarsUpdated` returns the same data for `FILTERED` and `UNFILTERED` `statsType`, and the `liquidity` value refreshes at most every 30 seconds.
* **More networks.** More networks and edge nodes will be added over time. Check the [changelog](https://docs.codex.io/changelog.md) for updates.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.