<!-- Canonical: https://docs.linea.build/network/build/tools/data-indexers/codex -->

> For the complete Linea documentation index, see [llms.txt](/llms.txt).
> Agents can fetch this page as Markdown at [https://docs.linea.build/network/build/tools/data-indexers/codex.md](https://docs.linea.build/network/build/tools/data-indexers/codex.md).

# Codex

[Codex](https://www.codex.io/) is a blockchain data API for real-time and historical DeFi data. Linea is fully supported. All Codex data primitives (tokens, prices, charts, holders, wallets, trades, and live subscriptions) are available for Linea, backed by indexing 80+ million tokens, 700 million wallets, and 28 billion transactions across 80+ networks.

## What you can do

All of Codex's token endpoints are available for Linea, allowing applications to:

-   **Discover tokens**: filter and search Linea tokens by liquidity, market cap, age, volume, holder count, and other metrics.
-   **Read prices and charts**: real-time and historical prices, plus OHLCV candlestick data for any Linea token across any timeframe.
-   **Look up holders and balances**: holder counts, top-holder distribution, and token balances for any Linea wallet.
-   **Query DEX trades and pairs**: swap events and token pair data across Linea DEXs.
-   **Stream live updates**: WebSocket subscriptions for price ticks, trades, and pair events on Linea tokens as they happen.

For a comprehensive list of endpoints available for Linea, see the [Codex Linea reference](https://docs.codex.io/networks/linea).

## Quick example

Fetch the top 10 Linea tokens by 24-hour trading volume, with price, market cap, liquidity, and holder metrics:

```ts
import { Codex } from "@codex-data/sdk";

const sdk = new Codex("YOUR_API_KEY");

const { filterTokens } = await sdk.queries.filterTokens({
  filters: {
    network: [59144], // Linea's network ID
    liquidity: { gt: 10000 },
  },
  rankings: [{ attribute: "volume24", direction: "DESC" }],
  limit: 10,
});

for (const result of filterTokens.results ?? []) {
  console.log({
    name: result.token.name,
    symbol: result.token.symbol,
    address: result.token.address,
    priceUSD: result.priceUSD,
    volume24: result.volume24,
    liquidity: result.liquidity,
    marketCap: result.marketCap,
    holders: result.holders,
  });
}
```

The same query as a raw GraphQL request:

```bash
curl -X POST https://graph.codex.io/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY" \
  -d '{
    "query": "query { filterTokens(filters: { network: [59144], liquidity: { gt: 10000 } }, rankings: [{ attribute: volume24, direction: DESC }], limit: 10) { results { token { name symbol address } priceUSD volume24 liquidity marketCap holders } } }"
  }'
```

## Integrating Codex

Codex exposes one GraphQL endpoint with several access modes. Pick the one that fits your delivery needs.

### GraphQL endpoint

All queries and mutations are issued as HTTPS POST to `https://graph.codex.io/graphql`. 65 query operations cover every data category listed above.

### TypeScript SDK

The [`@codex-data/sdk`](https://www.npmjs.com/package/@codex-data/sdk) package is a thin wrapper around the GraphQL API with typed queries, mutations, and built-in subscription handling.

```bash
npm install @codex-data/sdk
```

### WebSocket subscriptions

24 real-time streams are available over `wss://graph.codex.io/graphql`, including price updates, chart data, trade events, new and updated DEX pairs, and wallet activity.

### Webhooks

For push-based delivery without a persistent WebSocket, Codex webhooks POST onchain events to your server as they occur.

## Resources

-   [Sign up for free](https://dashboard.codex.io/signup) - 10,000 requests/month on the free plan
-   [Linea reference](https://docs.codex.io/networks/linea) - Linea-specific endpoint coverage
-   [Full API documentation](https://docs.codex.io/)
-   [GraphQL Explorer](https://docs.codex.io/explore) — interactively build and test queries
-   [Recipes and guides](https://docs.codex.io/recipes)
-   [GitHub](https://github.com/Codex-Data)
-   [Discord](https://discord.com/invite/mFpUhT3vAq)
