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

<div data-generated>
  ## 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
  }

  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
  }

  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
    identitySource: String
    identityUpdatedAt: Int
    polymarket: WalletPolymarketProfile
    tokensCreatedCount: Int
    tokensMigratedCount: Int
  }

  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
    isCashbackEnabled: Boolean
    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 Token2022Extensions {
    scaledUiAmountConfig: Token2022ScaledUiAmountConfig
  }

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

  type TokenExtensions {
    token2022: Token2022Extensions
    b20: B20Extensions
  }

  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
  }

  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
    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!]
  }

  type PooledTokenValues {
    token0: String
    token1: String
  }

  type UniswapV4Data {
    uniswapV4HookAddress: String
    isToken0NetworkToken: Boolean
    isDynamicFee: Boolean
    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
    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
  }
  ```
</div>

<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.
</Note>

### Example

<a href="/explore" target="_blank" rel="noopener noreferrer">Test this query in the Explorer →</a>

```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
* 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`.

### Troubleshooting Tips

<AccordionGroup>
  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="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](http://four.meme) (BNB Chain) and Flap (Robinhood Chain, `networkId` 4663).

    ```graphql theme={null}
    {
      getBars(
        symbol: "0x4a380618777eed8d513bcd6e983df3c5d2ba7777:4663"
        from: 1784105000
        to: 1784118000
        resolution: "15"
        symbolType: TOKEN
      ) {
        o
        h
        l
        c
        t
        volume
      }
    }
    ```
  </Accordion>

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

  <Accordion title="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](/recipes/charts).
  </Accordion>

  <Accordion title="Incorrect values or errors returned with resolutions under 1m">
    Our chart data for under 1m (`1S, 5S, 15S, 30S`) only goes back 24 hours due to the volume of data required at those resolutions.
  </Accordion>

  <Accordion title="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.
  </Accordion>
</AccordionGroup>

### Related Recipes

* [Charts](/recipes/charts): Render token charts with OHLCV data and real-time updates
