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

# getDetailedPairStats

> Returns bucketed stats for a given token within a pair.

<div data-generated>
  ## GraphQL

  ```
  type Query {
    getDetailedPairStats(
      pairAddress: String!
      networkId: Int!
      tokenOfInterest: TokenOfInterest
      timestamp: Int
      durations: [DetailedPairStatsDuration]
      bucketCount: Int
      statsType: TokenPairStatisticsType
    ): DetailedPairStats
  }

  enum TokenOfInterest {
    token0
    token1
  }

  enum TokenPairStatisticsType {
    FILTERED
    UNFILTERED
  }

  enum DetailedPairStatsDuration {
    day30
    week1
    day1
    hour12
    hour4
    hour1
    min15
    min5
  }

  type DetailedPairStatsBucketTimestamp {
    start: Int!
    end: Int!
  }

  type DetailedPairStatsStringMetrics {
    change: Float
    currentValue: String
    previousValue: String
    buckets: [String]!
  }

  type WindowedDetailedCurrencyPairStats {
    volume: DetailedPairStatsStringMetrics
    buyVolume: DetailedPairStatsStringMetrics
    sellVolume: DetailedPairStatsStringMetrics
    open: DetailedPairStatsStringMetrics
    highest: DetailedPairStatsStringMetrics
    lowest: DetailedPairStatsStringMetrics
    close: DetailedPairStatsStringMetrics
    liquidity: DetailedPairStatsStringMetrics
  }

  type DetailedPairStatsNumberMetrics {
    change: Float
    currentValue: Int
    previousValue: Int
    buckets: [Int]!
  }

  type WindowedDetailedNonCurrencyPairStats {
    transactions: DetailedPairStatsNumberMetrics
    buys: DetailedPairStatsNumberMetrics
    sells: DetailedPairStatsNumberMetrics
    traders: DetailedPairStatsNumberMetrics
    buyers: DetailedPairStatsNumberMetrics
    sellers: DetailedPairStatsNumberMetrics
  }

  type WindowedDetailedPairStats {
    duration: DetailedPairStatsDuration!
    start: Int!
    end: Int!
    timestamps: [DetailedPairStatsBucketTimestamp]!
    statsUsd: WindowedDetailedCurrencyPairStats!
    statsNonCurrency: WindowedDetailedNonCurrencyPairStats!
  }

  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 DetailedPairStats {
    pairAddress: String!
    networkId: Int!
    tokenOfInterest: TokenOfInterest
    lastTransaction: Int
    statsType: TokenPairStatisticsType!
    stats_min5: WindowedDetailedPairStats
    stats_min15: WindowedDetailedPairStats
    stats_hour1: WindowedDetailedPairStats
    stats_hour4: WindowedDetailedPairStats
    stats_hour12: WindowedDetailedPairStats
    stats_day1: WindowedDetailedPairStats
    stats_week1: WindowedDetailedPairStats
    stats_day30: WindowedDetailedPairStats
    bucketCount: Int
    queryTimestamp: Int
    pair: Pair
  }
  ```
</div>

### Example

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

```graphql theme={null}
{
  getDetailedPairStats(
    pairAddress: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
    networkId: 1
    tokenOfInterest: token0
    durations: [min5, hour1, hour4, hour12, day1]
  ) {
    pairAddress
    networkId
    tokenOfInterest
    statsType
    lastTransaction
    pair {
      token0
      token1
      token0Data {
        address
        name
        symbol
      }
      token1Data {
        address
        name
        symbol
      }
    }
    stats_hour1 {
      statsUsd {
        volume {
          currentValue
          previousValue
          change
        }
        buyVolume {
          currentValue
          previousValue
          change
        }
        sellVolume {
          currentValue
          previousValue
          change
        }
      }
      statsNonCurrency {
        transactions {
          currentValue
          previousValue
          change
        }
        buyers {
          currentValue
          previousValue
          change
        }
        sellers {
          currentValue
          previousValue
          change
        }
      }
    }
  }
}
```

### Usage Guidelines

* Query using `pairAddress` and `networkId` (not the combined pair ID format)
* Use `tokenOfInterest` (`token0` or `token1`) to specify which token's perspective to use for buy/sell calculations
* Use `durations` array to request specific time windows: `min5`, `min15`, `hour1`, `hour4`, `hour12`, `day1`, `week1`, `day30`
* Stats are returned in separate fields like `stats_hour1`, `stats_day1`, etc. based on requested durations
* `statsUsd` contains USD-denominated metrics (volume, buyVolume, sellVolume)
* `statsNonCurrency` contains count metrics (transactions, buyers, sellers, buys, sells)
* Each metric includes `currentValue`, `previousValue`, and `change` (percent change in decimal format)
* Use `buckets` array within each metric for granular time-series data

### Troubleshooting Tips

<AccordionGroup>
  <Accordion title="What does tokenOfInterest affect?">
    `tokenOfInterest` determines the perspective for buy/sell classification. If set to `token1`, a "buy" means buying token1 (selling token0), and vice versa. This affects buyVolume, sellVolume, buyers, and sellers metrics.
  </Accordion>

  <Accordion title="What's the difference between FILTERED and UNFILTERED statsType?">
    `FILTERED` stats exclude suspected bot/MEV activity to show organic trading. `UNFILTERED` includes all transactions. Use `statsType` in the response to see which type was returned.
  </Accordion>

  <Accordion title="How do I use the buckets array?">
    Each metric includes a `buckets` array with values for sub-intervals within the duration. For example, `stats_hour1` might have 12 buckets of 5 minutes each. Use the `timestamps` array to map bucket indices to time ranges.
  </Accordion>

  <Accordion title="Why is change showing as null?">
    The `change` field requires both `currentValue` and `previousValue` to calculate. For very new pairs or time windows with no previous data, `change` may be null.
  </Accordion>

  <Accordion title="How do I get historical stats?">
    Use the `timestamp` parameter to query stats as of a specific point in time. By default, stats are returned for the current time.
  </Accordion>

  <Accordion title="How do I obtain historical liquidity data, token prices, and volumes for a pool?">
    `getDetailedPairStats` is the most accurate source of historical pool stats — pass the `pairAddress`, `networkId`, and the durations you need (`min5`, `hour1`, `day1`, etc.). `getBars` is also useful for OHLCV-style time series. Note that `getTokenPrices` returns a weighted price across all of a token's pools — individual pool prices can differ.
  </Accordion>
</AccordionGroup>

### Related Recipes

* [Discover Tokens](/recipes/discover-tokens): Build token discovery pages with trending data, filters, and search
