Skip to main content

What is a Query?

A query is a one-time request for data. You send a GraphQL query to the Codex API over HTTP, and you get back a response with the data you asked for. Queries are the standard way to fetch token prices, wallet stats, historical bars, holder lists, and everything else in the API. Every query you run counts as 1 request against your plan’s monthly limit.
Not sure whether to use a query or a subscription? See Queries vs Subscriptions for a side-by-side comparison and endpoint mapping.

When to Use Queries

  • Fetching current state — token prices, metadata, pair stats, wallet balances
  • Historical data — OHLCV bars, trade events, wallet charts
  • Paginated lists — filtering tokens, wallets, pairs, or events with cursor-based pagination
  • One-time lookups — loading a page, responding to a user action, backfilling data
If you need data pushed to you continuously in real-time (e.g. live price feeds or streaming trades), use Subscriptions instead.

How It Works

Send a POST request to https://graph.codex.io/graphql with your API key in the Authorization header. To see a reference of all available queries, go to the API Reference.

Examples

Try it

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

const sdk = new Codex("your-api-key")

const { getTokenPrices } = await sdk.query(gql`
  query {
    getTokenPrices(inputs: [{ address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", networkId: 56 }]) {
      priceUsd
      timestamp
      address
    }
  }
`)
fetch("https://graph.codex.io/graphql", {
  method: "POST",
  headers: {
    "Authorization": apiKey,
  },
  body: JSON.stringify({ query: 'query { getTokenPrices(inputs: [{ address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", networkId: 56 }]) { priceUsd timestamp address } }' }),
})