Skip to content

Commit 05df8ba

Browse files
committed
2 parents 76d2fb9 + 2f186dd commit 05df8ba

12 files changed

Lines changed: 356 additions & 20 deletions

File tree

docs/trading/crypto-price-api/crypto-ohlc-candle-k-line-api.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ Get real-time and historical OHLC (Open, High, Low, Close) candle data, K-line c
2020
| How do I get OHLCV data for a token using Bitquery? | **Last 7 Days** [Crypto Price API](/docs/trading/crypto-price-api/introduction/) ; **historical:** [DEXTradeByTokens OHLC](/docs/cubes/dextradesbyTokens/#how-do-i-get-ohlc-in-a-dextradebytokens-query) |
2121
| How do I get OHLC in a DEXTradeByTokens query? | [DEXTradeByTokens OHLC](/docs/cubes/dextradesbyTokens/#how-do-i-get-ohlc-in-a-dextradebytokens-query) (for **historical** OHLC or DEX-level control) |
2222
| How do I get historical OHLCV for a Solana token? | **Main OHLC:** [Crypto Price API — Quick start](/docs/trading/crypto-price-api/introduction/#quick-start) · [Tokens cube](/docs/trading/crypto-price-api/tokens/) · **Historical / DEX:** [Historical OHLCV on Solana](/docs/blockchain/Solana/solana-dextrades/#how-do-i-get-historical-ohlcv-for-a-solana-token) · [Solana OHLC API](/docs/blockchain/Solana/solana-dextrades/#solana-ohlc-api) |
23-
| How do I get the current price of a token using Bitquery API? | [Quick start](/docs/trading/crypto-price-api/introduction/#quick-start) · [Tokens cube](/docs/trading/crypto-price-api/tokens/) · [Examples](/docs/trading/crypto-price-api/examples/) |
23+
| How do I get the current price of a token using Bitquery API? | **Recommended:** [Pairs + rank 1 (top market)](/docs/trading/crypto-price-api/pairs#most-accurate-token-price) · [Quick start](/docs/trading/crypto-price-api/introduction/#quick-start) · [Examples](/docs/trading/crypto-price-api/examples/) |
24+
| Which cube gives the most accurate price for one token? | [Pairs with `Ranking: { Position: { eq: 1 } }`](/docs/trading/crypto-price-api/pairs#most-accurate-token-price) — prices from the token's top market rather than a blend across all its pools |
2425
| How do I get price change percentage for a token? | [Price change](/docs/start/starter-queries/#volume-of-multiple-tokens-across-different-chains) |
2526
| How do I get 1-minute OHLC candles for a DEX pair? | **Main:** [Your first OHLC query](#your-first-ohlc-query) (`Duration: { eq: 60 }`) · [Pairs cube](/docs/trading/crypto-price-api/pairs/) · **Historical:** [DEX OHLC pattern](/docs/cubes/dextradesbyTokens/#how-do-i-get-ohlc-in-a-dextradebytokens-query) |
2627
| How do I get the all-time high (ATH) price of a token? | [Solana ATH example](/docs/blockchain/Solana/solana-dextrades/#get-ath-market-cap-of-tokens)|
27-
| Is there an API to get token price in USD on Solana? | [Crypto Price API — Quick start](/docs/trading/crypto-price-api/introduction/#quick-start) · [Tokens cube](/docs/trading/crypto-price-api/tokens/) · [Latest USD (Solana DEX trades)](/docs/blockchain/Solana/solana-dextrades/#latest-usd-price-of-a-token) |
28+
| Is there an API to get token price in USD on Solana? | [Pairs + rank 1 (top market)](/docs/trading/crypto-price-api/pairs#most-accurate-token-price) · [Crypto Price API — Quick start](/docs/trading/crypto-price-api/introduction/#quick-start) · [Latest USD (Solana DEX trades)](/docs/blockchain/Solana/solana-dextrades/#latest-usd-price-of-a-token) |
2829
| How do I use DEXTradeByTokens vs DEXTrades for OHLCV? | [OHLCV: which cube?](/docs/cubes/dextradesbyTokens/#how-do-i-use-dextradebytokens-vs-dextrades-for-ohlcv) · [DEXTrades cube](/docs/cubes/dextrades/) |
2930

3031
## What is OHLC Data?
@@ -202,23 +203,26 @@ Use the **Currency** cube when you want a unified price view of an asset across
202203

203204
[Learn more about Currency Cube ➤](/docs/trading/crypto-price-api/currency/)
204205

205-
### **Tokens Cube** - Chain-Specific Token Data
206+
### **Tokens Cube** - Chain-Wide Blended Candles
206207

207-
Use the **Tokens** cube when you need OHLC data for a specific token on a specific blockchain.
208+
Use the **Tokens** cube when you want one candle per token per chain, or a stream of candles for every token on a chain.
208209

209210
**Key Features:**
210211
- Aggregates across all pairs for that token
211212
- Can provide both chain specific and chain agnostic prices
212213
- Can provide only USD-quoted prices
213214
- Can combine volume and price data from all chains
214215

216+
> Because the candle blends every pool where the token is base, thin pools contribute to it as well. For candles on **one specific token**, prefer the Pairs cube with rank 1 (below).
217+
215218
[Learn more about Tokens Cube ➤](/docs/trading/crypto-price-api/tokens/)
216219

217-
### **Pairs Cube** - Trading Pair Specific Data
220+
### **Pairs Cube** - Top Market and Pair-Specific Candles
218221

219-
Use the **Pairs** cube when you need OHLC data for specific trading pairs on specific DEXs.
222+
Use the **Pairs** cube for OHLC on a specific market — and, with the rank filter, for the most accurate candles on a specific **token**.
220223

221224
**Key Features:**
225+
- **Recommended for a single token:** add `Ranking: { Position: { eq: 1 } }` to get candles from the token's top market instead of a blend across all pools ([how and why](/docs/trading/crypto-price-api/pairs#most-accurate-token-price))
222226
- Pair-specific OHLC data (e.g., ETH/USDC on Uniswap)
223227
- Can be quoted in USD or quote token
224228
- Market/DEX-specific data

docs/trading/crypto-price-api/currency.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ description: "Query currency-level crypto prices and conversions with Bitquery T
66

77
The Currency Cube provides a unified, chain-agnostic price for an asset in USD, such as Bitcoin by aggregating prices and volumes from all its representations (e.g., WBTC, cbBTC, and other bridged or wrapped forms) across all supported chains. This multi-chain cryptocurrency price data approach ensures consistent pricing across different blockchain implementations.
88

9+
:::note Use this for cross-chain assets, not for a single token
10+
Currency prices aggregate **across chains and token representations**, so use this cube when you want one global number for an asset like BTC or ETH. For the price of a **specific token on a specific market**, use the [Pairs cube with `Ranking: { Position: { eq: 1 } }`](/docs/trading/crypto-price-api/pairs#most-accurate-token-price). Note that `Ranking` is **not** available on `Currencies` — it exists on `Trades`, `Pairs`, and `Tokens` only.
11+
:::
12+
913
### How OHLC is Calculated
1014

1115
The OHLC values (Open, High, Low, Close) are determined across all chains and token representations of an asset for the selected interval (e.g., 60 seconds):

docs/trading/crypto-price-api/examples.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,72 @@ description: "Quick Start Examples via Bitquery Trading APIs for multi-chain pri
44
---
55
# Quick Start Examples
66

7+
## Most Accurate Price for a Token (Top Market, Rank 1) {#most-accurate-price-for-a-token}
8+
9+
The recommended way to price a **specific token**: query the `Pairs` cube with `Ranking: { Position: { eq: 1 } }` to get the price from the token's **top market** — the pool currently carrying the most volume for it — instead of a value blended across every pool it trades in. Thin, fragmented pools therefore cannot pull the number away from the market where the token actually trades.
10+
11+
Full explanation, streaming variant, and caveats: [Getting the Most Accurate Token Price](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
12+
13+
[Run query ➤](https://ide.bitquery.io/Token-price-from-top-market--rank-1_2)
14+
15+
```graphql
16+
{
17+
Trading {
18+
Pairs(
19+
where: {
20+
Token: {
21+
Address: { is: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" }
22+
Network: { is: "Solana" }
23+
}
24+
Ranking: { Position: { eq: 1 } }
25+
Interval: { Time: { Duration: { eq: 60 } } }
26+
Price: { IsQuotedInUsd: true }
27+
}
28+
limit: { count: 1 }
29+
orderBy: { descending: Block_Time }
30+
) {
31+
Token {
32+
Symbol
33+
Address
34+
}
35+
QuoteToken {
36+
Symbol
37+
}
38+
Market {
39+
Protocol
40+
Address
41+
Network
42+
}
43+
Price {
44+
IsQuotedInUsd
45+
Ohlc {
46+
Open
47+
High
48+
Low
49+
Close
50+
}
51+
}
52+
Ranking {
53+
Position
54+
Weight
55+
}
56+
Volume {
57+
Usd
58+
}
59+
Block {
60+
Time
61+
}
62+
}
63+
}
64+
}
65+
```
66+
67+
`Price.Ohlc.Close` is the latest price on the top market. Keep `Price: { IsQuotedInUsd: true }` in the filter — every market also publishes rows priced in **quote token units**, so without it a WBTC/WSOL market would return the price of WBTC in SOL rather than in dollars.
68+
69+
`Ranking.Weight` tells you how concentrated the token's liquidity is: near 1 means a single pool drives the price; a low value means it is fragmented across many pools — the case where this query differs most from the blended `Tokens` price.
70+
71+
Change `query` to `subscription` and drop `limit`/`orderBy` to stream it live.
72+
773
## Real-Time Token Prices in USD on Solana
874

975
Stream live OHLC (Open, High, Low, Close) price and volume data for all tokens on Solana, quoted directly in USD. Useful for dashboards, analytics, or bots that need stable fiat-based prices.
@@ -216,6 +282,8 @@ subscription {
216282

217283
Get a snapshot of tokens with aggregated USD volume and average price over the last 24 hours. The query uses `limitBy: { count: 1, by: Token_Id }` to return one row per token, and conditional metrics (`Volume.Usd(if: ...)`, `Price.Average.Mean(..., if: ...)`) to show volume and price for the last 1h, 4h, and 24h. Useful for dashboards, top-movers lists, or comparing short-term vs daily metrics.
218284

285+
> The `Tokens` cube is the right choice here: volume is summed across all of a token's pools. Note that its prices are blended across those pools too — to price one specific token from its top market instead, use [Pairs with rank 1](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
286+
219287
[Run query ➤](https://ide.bitquery.io/aggregated-data-for-tokens)
220288

221289
```graphql
@@ -559,6 +627,8 @@ query {
559627

560628
Fetch the top 10 tokens by 5-minute percentage price change (USD-based), only including tokens with at least $100k trading volume. Ideal for building a "top movers" list.
561629

630+
> Scanning every token on a chain is exactly what the `Tokens` cube is for. Once you have picked a token out of the list, price it from its top market with [Pairs + rank 1](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
631+
562632
Here we have selected the filter `Price: {IsQuotedInUsd: true}`, this means that any price values such as OHLC or Average indicators will be in USD. If you want them in quote currency, change the filter to `Price: {IsQuotedInUsd: false}`.
563633

564634
This stream uses [expressions](/docs/graphql/capabilities/expression/)
@@ -641,6 +711,8 @@ This stream uses [expressions](/docs/graphql/capabilities/expression/)
641711

642712
Stream the top 10 tokens on Solana by 5-minute price change (in USD), filtered by $100k+ volume. Updates continuously.
643713

714+
> As above, this is a chain-wide scan. For a watchlist of specific tokens, stream their top markets instead — see [Watchlist: top-market price for several tokens](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
715+
644716
Here we have selected the filter `Price: {IsQuotedInUsd: true}`, this means that any price values such as OHLC or Average indicators will be in USD. If you want them in quote currency, change the filter to `Price: {IsQuotedInUsd: false}`.
645717

646718
This stream uses [expressions](/docs/graphql/capabilities/expression/)
@@ -723,6 +795,8 @@ Calculate the percentage drawdown (price decline) for tokens of a specific curre
723795

724796
This query uses [expressions](/docs/graphql/capabilities/expression/) to calculate drawdown as: `((Close - Open) / Open) * 100`.
725797

798+
> This compares a currency's token representations against each other, so `Tokens` fits. To measure one token's drawdown on the market where it actually trades, run the same expression against [Pairs with rank 1](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
799+
726800
> **Note:** You can use `Token: {Address: {is: "token_address"}}` filter instead of `Currency: {Id: {is: "bid:bitcoin"}}` to filter by token address. We include `Volume: { Usd: { gt: 10 } }` to filter out tokens with very low trading volume.
727801
728802
[Run query](https://ide.bitquery.io/Drawdown-of-a-token-last-hour)

docs/trading/crypto-price-api/introduction.mdx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ Use the same **`bid:<chain>`** convention as **`Token.Id`**.
9797

9898
## Quick Start {#quick-start}
9999

100+
:::tip Pricing one specific token? Start with Pairs + rank 1
101+
The stream below is a **firehose** of every token on every chain, and the `Tokens` cube is the right choice for it. If instead you want the price of **one token**, query the [**Pairs** cube with `Ranking: { Position: { eq: 1 } }`](/docs/trading/crypto-price-api/pairs#most-accurate-token-price) — it returns the price from the token's **top market** rather than a blend across all of its pools, which matters for tokens with fragmented liquidity.
102+
:::
103+
100104
[Run Stream >](https://ide.bitquery.io/1-second-crypto-price-stream)
101105

102106
> Note: A `Volume: {Usd: {gt: 5}}` filter is applied to remove extreme outliers; the price stream already pre-filters outliers—this is an additional check.
@@ -247,9 +251,9 @@ Each message contains:
247251

248252
The Price APIs have three core data cubes:
249253

250-
- **Tokens**: Price data for a specific token on a specific chain. Use this when you care about chain-specific prices like USDT on Solana.
254+
- **Tokens**: One blended price per token per chain, aggregated across every pool the token trades in. Use it for chain-wide streams and per-chain aggregates.
251255
- **Currencies**: An aggregated view of tokens that represent the same underlying asset. For example, tokens like cbBTC, WBTC, and other Bitcoin-wrapped tokens are all grouped under the Bitcoin currency.
252-
- **Pairs**: Price and volume data for token pairs on specific markets/protocols. E.g., SOL/USDC on Raydium (Solana) or ETH/USDT on Uniswap (Ethereum).
256+
- **Pairs**: Price and volume data for token pairs on specific markets/protocols. E.g., SOL/USDC on Raydium (Solana) or ETH/USDT on Uniswap (Ethereum). **This is also the recommended cube for a specific token's price** — filter to its top market with [`Ranking: { Position: { eq: 1 } }`](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
253257

254258
> Note: Expressions are supported in this API.
255259
@@ -326,6 +330,8 @@ It takes amounts and prices from all chains that use BTC and wrapped versions (i
326330

327331
Let's say you don't want a chain agnostic view, but want to focus on a particular chain. How to stream or query prices for it? This is where tokens come in.
328332

333+
> **Note:** the price below is blended across **all pools** where the token is base. For a single token, the [rank-1 Pairs query](/docs/trading/crypto-price-api/pairs#most-accurate-token-price) prices it from its top market instead — recommended whenever you care about one specific token.
334+
329335
> Note: We include `Volume: {Usd: {gt: 5}}` to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.
330336
331337
```graphql
@@ -469,6 +475,8 @@ subscription {
469475
This is the 3rd cube in these set of APIs. The Pairs cube gives you price, volume, and market-level trading data between two tokens — a base token and a quote token.
470476
We will breakdown in detail how base token and Quote are chosen in the next section.
471477

478+
> **Recommended for single-token prices:** add `Ranking: { Position: { eq: 1 } }` to a Pairs query to get a token's price from its **top market** — the pool carrying the most volume for it. See [Getting the Most Accurate Token Price](/docs/trading/crypto-price-api/pairs#most-accurate-token-price).
479+
472480
> **Tip**: Use `TokenId` instead of `Token.Address` to fetch all variants of the same token (e.g., ETH, WETH, bridged ETH) across multiple chains.
473481
474482
> Note: We include `Volume: {Usd: {gt: 5}}` to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.
@@ -565,25 +573,32 @@ Use `TargetVolume` to get price intervals aggregated over a volume threshold:
565573

566574
## When to Choose Which Cube (Token, Currency, Pair)?
567575

576+
:::tip The short answer
577+
For the price of a **specific token**, use **`Pairs` with `Ranking: { Position: { eq: 1 } }`** — see [Getting the Most Accurate Token Price](/docs/trading/crypto-price-api/pairs#most-accurate-token-price). Use `Tokens` for chain-wide streams and per-chain aggregates, and `Currencies` for one cross-chain number per asset.
578+
:::
579+
580+
### Use the **`Pairs`** cube when:
581+
582+
- You want the **price of a specific token** — filter to its top market with `Ranking: { Position: { eq: 1 } }` so thin pools do not affect the number ([how and why](/docs/trading/crypto-price-api/pairs#most-accurate-token-price)).
583+
- You want **pair-level trading data** (e.g., SOL/USDC, ETH/DAI).
584+
- You’re analyzing trading activity **on a specific market or DEX** (e.g., Uniswap, PancakeSwap, Raydium).
585+
- You need **OHLC, volume, liquidity**, and market-specific pricing between two tokens.
586+
- You're exploring **price arbitrage** or spreads across chains or platforms.
587+
568588
### Use the **`Tokens`** cube when:
569589

570-
- You want token price data **on a specific blockchain**.
571-
- You're interested in metrics like OHLC, volume, and moving averages **for one network** (e.g., USDC on Solana or ETH on Arbitrum).
572-
- You want to stream or query **chain-specific** price movements.
590+
- You want a **firehose** of price updates for every token on a chain.
591+
- You want **one chain-wide number per token**, blended across all of its pools, rather than the price on a single market.
592+
- You're interested in **aggregate volume across all of a token's pools**, or the currency-level `Supply` and `MarketCap` fields.
593+
594+
> For a **single token's price**, prefer `Pairs` with rank 1: the `Tokens` price is a volume-weighted blend of every pool, so thin pools can pull it away from the primary market. See [Tokens cube](/docs/trading/crypto-price-api/tokens).
573595
574596
### Use the **`Currencies`** cube when:
575597

576598
- You want a **chain-agnostic view** of a token (e.g., BTC across Bitcoin, Ethereum (WBTC), Solana, etc.).
577599
- You need a **global price** for a currency, combining its various representations.
578600
- You're looking for **aggregated OHLC and average prices** for a token across chains.
579601

580-
### Use the **`Pairs`** cube when:
581-
582-
- You want **pair-level trading data** (e.g., SOL/USDC, ETH/DAI).
583-
- You’re analyzing trading activity **on a specific market or DEX** (e.g., Uniswap, PancakeSwap, Raydium).
584-
- You need **OHLC, volume, liquidity**, and market-specific pricing between two tokens.
585-
- You're exploring **price arbitrage** or spreads across chains or platforms.
586-
587602
## Crypto Price API for TradingView
588603

589604
With the new Price API, you can simply feed the stream to your custom datafeed object in the TradingView code and have it update charts in real-time.
@@ -603,6 +618,10 @@ import VideoPlayer from "../../../src/components/videoplayer.js";
603618
q: "How do I get real-time crypto prices and OHLC candles?",
604619
a: "Use Trading.Tokens, Trading.Pairs, or Trading.Currencies for aggregated USD prices and OHLC over the last ~30 days. For older history, build candles from DEXTradeByTokens on the chain you need.",
605620
},
621+
{
622+
q: "Which cube gives the most accurate price for a specific token?",
623+
a: "Trading.Pairs filtered with Ranking: { Position: { eq: 1 } }. That returns the price on the token's top market — the pool contributing the most volume — instead of the Tokens cube's blend across every pool, which thin pools can pull off the primary market's price. See Getting the Most Accurate Token Price on the Pairs cube page.",
624+
},
606625
{
607626
q: "What is the difference between Crypto Price API and Crypto Trades API?",
608627
a: "Crypto Price API gives aggregated price feeds and OHLC by token or pair. Crypto Trades API returns individual swap rows with USD price, market cap, and supply on every trade.",

0 commit comments

Comments
 (0)