> ## 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.

# getBars

> Returns bar chart data to track price changes over time. Reference for the getBars query in the Codex API: arguments, response fields, and usage.

## GraphQL

```
type Query {
  getBars(
    symbol: String!
    from: Int!
    to: Int!
    resolution: String!
    currencyCode: String
    removeLeadingNullValues: Boolean
    removeEmptyBars: Boolean
    quoteToken: QuoteToken
    statsType: TokenPairStatisticsType
    countback: Int
    symbolType: SymbolType
  ): BarsResponse
}

type SocialLinks {
  bitcointalk: String
  blog: String
  coingecko: String
  coinmarketcap: String
  discord: String
  email: String
  facebook: String
  github: String
  instagram: String
  linkedin: String
  reddit: String
  slack: String
  telegram: String
  twitch: String
  twitter: String
  website: String
  wechat: String
  whitepaper: String
  youtube: String
  tiktok: String
}

type TokenInfo {
  id: String!
  address: String!
  circulatingSupply: String
  cmcId: Int
  gridAssetId: String
  bluechipRating: String
  isScam: Boolean
  name: String
  networkId: Int!
  symbol: String!
  totalSupply: String
  imageThumbHash: String
  imageThumbUrl: String
  imageSmallUrl: String
  imageLargeUrl: String
  imageBannerUrl: String
  videoExternalUrl: String
  description: String
}

type OrganizationUrl {
  url: String!
  type: String
}

type OrganizationSocial {
  url: String!
  type: String
}

type AssetDeployment {
  id: String!
  networkId: Int!
  address: String!
  standard: String
  assetId: String!
  rootId: String!
  token: EnhancedToken
}

type Asset {
  id: String!
  name: String
  description: String
  ticker: String
  type: String
  status: String
  icon: String
  rootId: String!
  assetDeployments: [AssetDeployment!]!
}

type Organization {
  name: String!
  foundingDate: String
  descriptionShort: String
  descriptionLong: String
  tagLine: String
  type: String
  sector: String
  urls: [OrganizationUrl!]!
  socials: [OrganizationSocial!]!
  logo: String
  icon: String
  header: String
  rootId: String!
  assets: [Asset!]!
}

type ExplorerTokenData {
  id: String!
  blueCheckmark: Boolean
  description: String
  divisor: String
  tokenPriceUSD: String
  tokenType: String
}

type Exchange {
  id: String!
  address: String!
  color: String
  name: String
  exchangeVersion: String
  iconUrl: String
  networkId: Int!
  tradeUrl: String
}

enum WalletCategory {
  NORMIE
  TOKEN_CREATOR
  EXCHANGE
  DEFI_EXCHANGE
  PAIR
  PAIR_TOKEN_HOLDER
  POOL_AUTHORITY
  STAKING_VAULT
  NOTORIOUS
  BURN
  LOCKER
}

type WalletFunding {
  fundedByAddress: String!
  fundedByLabel: String
  fundedAt: Int!
  tokenAddress: String!
  networkId: Int!
  amount: String!
  transactionHash: String!
}

type WalletPolymarketProfile {
  proxyWallet: String!
  xUsername: String
  displayName: String
  pseudonym: String
  profileImageUrl: String
  verifiedBadge: Boolean
  displayUsernamePublic: Boolean
  fetchedAt: Int!
}

type Wallet {
  address: String!
  category: WalletCategory
  firstSeenTimestamp: Int
  firstFunding: WalletFunding
  identityLabels: [String!]
  avatarUrl: String
  displayName: String
  twitterId: String
  twitterUsername: String
  telegramId: String
  telegramUsername: String
  website: String
  discordId: String
  discordUsername: String
  githubId: String
  githubUsername: String
  farcasterId: String
  farcasterUsername: String
  description: String
  ethosScore: Int
  ethosLevel: String
  ethosVerified: Boolean
  tradeSourceIds: [String!]
  identitySource: String
  identityUpdatedAt: Int
  polymarket: WalletPolymarketProfile
  tokensCreatedCount: Int
  tokensMigratedCount: Int
}

enum FeeMode {
  CREATOR_FEE
  CASHBACK
  HOLDER_REWARDS
}

type LaunchpadData {
  launchpadName: String
  graduationPercent: Float
  poolAddress: String
  completedAt: Int
  completed: Boolean
  completedSlot: Int
  migratedSlot: Int
  migratedAt: Int
  migrated: Boolean
  migratedPoolAddress: String
  launchpadProtocol: String
  launchpadIconUrl: String
  feeModes: [FeeMode!]
  holderRewardFeeBps: Int
  holderRewardQuoteMint: String
  category: String
}

type TokenExtrema {
  id: String!
  address: String!
  networkId: Int!
  athPrice: String!
  athPriceTimestamp: Int!
  atlPrice: String!
  atlPriceTimestamp: Int!
  athFdv: String!
  athFdvTimestamp: Int!
  atlFdv: String!
  atlFdvTimestamp: Int!
  athCircMc: String!
  athCircMcTimestamp: Int!
  atlCircMc: String!
  atlCircMcTimestamp: Int!
}

type CoinCommunity {
  id: String!
  createdAt: Int!
  postCount: Int!
  memberCount: Int!
  likeCount: Int!
  lastPostAt: Int
}

type Token2022ScaledUiAmountConfig {
  authority: String
  multiplier: Float!
  newMultiplierEffectiveTimestamp: String
  newMultiplier: Float
}

type Token2022TransferFee {
  epoch: String!
  transferFeeBasisPoints: Int!
  maximumFee: String!
}

type Token2022TransferFeeConfig {
  transferFeeConfigAuthority: String
  olderTransferFee: Token2022TransferFee!
  newerTransferFee: Token2022TransferFee!
}

type Token2022Extensions {
  scaledUiAmountConfig: Token2022ScaledUiAmountConfig
  transferFeeConfig: Token2022TransferFeeConfig
}

type B20Extensions {
  multiplier: String
  multiplierObservedAt: String
  pausedTransfer: Boolean
  pausedMint: Boolean
  pausedBurn: Boolean
  supplyCap: String
}

type RobinhoodStockTokenExtensions {
  uid: String!
  multiplier: String
  multiplierObservedAt: String
  newMultiplier: String
  newMultiplierEffectiveAt: String
  oraclePaused: Boolean
}

type XStockTokenExtensions {
  multiplier: String
  multiplierObservedAt: String
  newMultiplier: String
  newMultiplierEffectiveAt: String
}

type TokenExtensions {
  token2022: Token2022Extensions
  b20: B20Extensions
  robinhoodStockToken: RobinhoodStockTokenExtensions
  xStock: XStockTokenExtensions
}

type Erc7572CustomInfo {
  type: String!
  featuredImage: String
  collaborators: [String!]
}

enum CategoryType {
  CANONICAL
  NARRATIVE
}

enum CategoryStatus {
  DRAFT
  ACTIVE
  ARCHIVED
}

type Category {
  id: String!
  name: String!
  shortName: String
  slug: String!
  description: String
  type: CategoryType!
  status: CategoryStatus!
  parentId: String
  memberCount: Int
}

enum RiskVerdict {
  SCAM
  HIGH_RISK
  CAUTION
  NEUTRAL
  VERIFIED
  VERIFIED_CONTESTED
}

enum RiskAnalysisCoverage {
  NOT_ANALYZED
  INCONCLUSIVE
  ANALYZED
  STALE
}

enum RiskReasonCode {
  PROOF_HONEYPOT_SIM
  PROOF_NON_TRANSFERABLE
  PROOF_TRANSFER_FEE_100
  PROOF_DEFAULT_FROZEN
  PROOF_POOL_TRAP_SIM
  AUTH_MINT
  AUTH_FREEZE
  AUTH_PERMANENT_DELEGATE
  AUTH_TRANSFER_HOOK
  AUTH_PAUSABLE
  AUTH_OWNER_NOT_RENOUNCED
  AUTH_CAN_TRANSFER_OWNERSHIP
  TAX_BUY_HIGH
  TAX_SELL_HIGH
  TAX_HONEYPOT_UNCONFIRMED
  TAX_PAUSED
  TAX_POOL_TRAP
  TAX_POOL_TRAP_HOOK_SHARED
  LIQ_MINIMAL
  LIQ_UNKNOWN
  LIQ_RUG_CLIFF
  LIQ_UNLOCKED
  LIQ_DRAINING
  HOLD_TOP10_CONCENTRATED
  HOLD_DEV_HEAVY
  HOLD_SNIPER_HEAVY
  HOLD_BUNDLER_HEAVY
  HOLD_INSIDER_HEAVY
  HOLD_INSIDER_DUMPED
  FLOW_ONE_WAY
  FLOW_WALLET_FARM
  FLOW_WASH_DOMINATED
  FLOW_BUNDLED_LAUNCH
  FLOW_MECHANICAL_TRADING
  FLOW_RING_DOMINATED
  REP_SERIAL_RUGGER
  REP_RISKY_CREATOR
  REP_SCAMMER_FUNDED
  REP_IMITATOR_SYMBOL
  REP_IMITATOR_NAME
  REP_IMITATOR_IMAGE
  LABEL_MANUAL_SCAM
  LABEL_VERIFIED
}

type TokenRisk {
  verdict: RiskVerdict
  score: Float
  flaggedAt: Int
  analyzedAt: Int
  coverage: RiskAnalysisCoverage
  reasons: [RiskReasonCode!]
  buyTax: Float
  sellTax: Float
}

type TokenIssuer {
  id: String!
  displayName: String
}

type EnhancedToken {
  id: String!
  address: String!
  cmcId: Int
  decimals: Int!
  isScam: Boolean
  name: String
  networkId: Int!
  symbol: String
  socialLinks: SocialLinks
  info: TokenInfo
  gridAssetId: String
  bluechipRating: String
  organization: Organization
  asset: Asset
  exchanges: [Exchange!]
  creatorAddress: String
  creator: Wallet
  creatorBalanceNBT: String
  createBlockNumber: Int
  createTransactionHash: String
  createdAt: Int
  mintable: String
  freezable: String
  isFreezableValid: Boolean
  isMintableValid: Boolean
  launchpad: LaunchpadData
  top10HoldersPercent: Float
  profanity: Boolean
  extrema: TokenExtrema
  coinCommunity: CoinCommunity
  extensions: TokenExtensions
  tokenStandardCustomData: Erc7572CustomInfo
  categories: [Category!]
  risk: TokenRisk
  issuer: TokenIssuer
}

type PooledTokenValues {
  token0: String
  token1: String
  invalidReserves: Boolean!
}

type CurrencyUnits {
  currency0: String!
  currency1: String!
  decimals0: Int!
  decimals1: Int!
}

type UniswapV4Data {
  uniswapV4HookAddress: String
  isToken0NetworkToken: Boolean
  isDynamicFee: Boolean
  currencyUnits: CurrencyUnits
  type: String!
}

type ArenaTradeData {
  tokenId: String
  type: String!
}

type PumpData {
  creator: String
  type: String!
}

union ProtocolData = UniswapV4Data | ArenaTradeData | PumpData

type PairProtocolCustomData {
  uniswapV4HookAddress: String
}

type Pair {
  address: String!
  exchangeHash: String!
  fee: Int
  id: String!
  networkId: Int!
  protocol: String
  tickSpacing: Int
  token0: String!
  token1: String!
  createdAt: Int
  token0Data: EnhancedToken
  token1Data: EnhancedToken
  pooled: PooledTokenValues
  virtualPooled: PooledTokenValues
  currencyUnits: CurrencyUnits
  protocolData: ProtocolData
}

type BarsResponse {
  o: [Float]!
  h: [Float]!
  l: [Float]!
  c: [Float]!
  t: [Int!]!
  s: String!
  volume: [String]
  volumeNativeToken: [String]
  buyers: [Int]!
  buys: [Int]!
  buyVolume: [String]!
  sellers: [Int]!
  sells: [Int]!
  sellVolume: [String]!
  liquidity: [String]!
  traders: [Int]!
  transactions: [Int]!
  poolFees: [String]
  baseFees: [String]
  priorityFees: [String]
  builderTips: [String]
  l1DataFees: [String]
  totalFees: [String]
  feeToVolumeRatio: [String]
  mevToTotalFeesRatio: [String]
  gasPerVolume: [String]
  averageCostPerTrade: [String]
  mevRiskLevel: [String]
  feeRegimeClassification: [String]
  sandwichRate: [String]
  pair: Pair!
}

enum QuoteToken {
  token0
  token1
}

enum TokenPairStatisticsType {
  FILTERED
  UNFILTERED
}

enum SymbolType {
  TOKEN
  POOL
}
```

> [!NOTE]
>
> On launchpads where a token's pair address equals its contract address at launch (e.g. four.meme on BNB Chain, Flap on Robinhood Chain), pass `symbolType: TOKEN` alongside a `tokenAddress:networkId` symbol. This follows the token to its current top pair after it migrates to a separate AMM pool — otherwise the query can resolve to the original launch pool and return a frozen, 0-volume price. See the [troubleshooting tips](#troubleshooting-tips) below for details.
>
> The same applies to any token address. With `symbolType` left out, `getBars` first looks for a pool at that address and only falls back to the token if there is none. Some tokens, such as stock tokens on Robinhood Chain, have an empty pool at their own address, so the query returns `no_data`. Pass `symbolType: TOKEN` whenever the symbol is a token address.

### Example

[Test this query in the Explorer →](https://docs.codex.io/explore.md)

```graphql theme={null}
{
  getBars(
    symbol: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2:1"
    from: 0
    to: 1752692400
    resolution: "60"
    countback: 10
    removeEmptyBars: true
  ) {
    o
    h
    c
    l
    volume
  }
}
```

### Usage Guidelines

* Maximum datapoints: 1500 per request. A range that would exceed 1,500 datapoints returns an error, it is not truncated.
* Use `countback: 1500` with `from: 0` for maximum results
* Add `removeEmptyBars: true` to eliminate gaps in low-activity tokens
* Use `currencyCode: "TOKEN"` for native token pricing instead of USD
* For charting by Market cap: multiply price data by `circulatingSupply` from `EnhancedToken`
* For volume, be sure to use `volume` instead of `v`. Due to large volume numbers exceeding max integer lengths, we needed to deprecate `v` in place of `volume`.
* Candle open, high, low and close follow the pool price after each event, not each trade's execution price. For per-trade prices use `priceUsd` from [`getTokenEvents`](https://docs.codex.io/api-reference/queries/gettokenevents).
* Bars have no "final" flag. A just-closed 1m candle can keep updating for a few seconds after the period ends, while the next candle is already updating. Treat a candle as closed about 5 seconds after its period ends, and re-fetch recent candles if you store history.
* A new 1m or 5m bar can take several seconds to appear after its first trade. Until it does, the last bar is the previous period, so its close can trail the live price while longer resolutions are already up to date. For a live price label, use [`getTokenPrices`](https://docs.codex.io/api-reference/queries/gettokenprices) instead of the last 1m close.

### Troubleshooting Tips

> [accordion] When should I use getBars vs getTokenBars?
>
> Use `getBars` when you want price data for a specific trading pair. Use `getTokenBars` when you want aggregate price data for a token across all its trading pairs — it uses weighted average pricing based on liquidity.

> [accordion] Wrong or inconsistent base token in pair (Token0 vs Token1)
>
> Omit `quoteToken` parameter to auto-detect the correct base token of the pair automatically.

> [accordion] Null or empty values returned
>
> -Check that your timestamp window is accurate and long enough for the resolution requested.\
> -Ensure the token has started trading (we do not index tokens until trades occur)\
> -Use `removeLeadingNullValues: true`

> [accordion] Launchpad token returns stale, flat, or 0-volume data (frozen price)
>
> Some launchpads deploy a token where the pair address equals the token contract address at launch, then migrate to a separate AMM pool once the bonding curve completes. Passing a bare `tokenAddress:networkId` symbol can resolve to the original launch pool, which stops trading after migration and returns a frozen, gap-filled price with `0` volume.
>
> **Fix:** add `symbolType: TOKEN` (all caps) to your query. This resolves to the token's current top pair and follows it across migration. `getTokenBars` is unaffected as it's already token-scoped.
>
> Affected launchpads include [four.meme](https://four.meme/en) (BNB Chain) and Flap (Robinhood Chain, `networkId` 4663).
>
> ```graphql theme={null}
> {
>   getBars(
>     symbol: "TOKEN_ADDRESS:4663"
>     from: 1784105000
>     to: 1784118000
>     resolution: "15"
>     symbolType: TOKEN
>   ) {
>     o
>     h
>     l
>     c
>     t
>     volume
>   }
> }
> ```

> [accordion] Integrating data with TradingView
>
> Our API fits right into TradingView's library. You can find docs for integrating with TradingView at [https://www.tradingview.com/free-charting-libraries/](https://www.tradingview.com/free-charting-libraries/).

> [accordion] Updating charts in real-time
>
> You can use `getBars` to do an initial fetch of bars and then subscribe to `onBarsUpdated` to keep it updated in real-time. More info on creating real-time charts is available [here](https://docs.codex.io/recipes/charts.md).

> [accordion] Incorrect values or errors returned with resolutions under 1m
>
> Sub-minute resolutions (`1S`, `5S`, `15S`, `30S`) are kept for about 24 hours due to the volume of data required at those resolutions. Older windows return forward-filled bars with no volume, so pass `removeEmptyBars: true` or check `volume`.

> [accordion] Can I get sparklines for a past time period?
>
> No — `tokenSparklines` only returns recent values. To approximate a sparkline for a past time window, call `getBars` for the desired range and extract the closing values for each bar.

### Related Recipes

* [Charts](https://docs.codex.io/recipes/charts.md): Render token charts with OHLCV data and real-time updates


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