Skip to main content

Crypto Tokens OHLC Candle K-Line API - Real-Time & Historical Price Data

Get real-time and historical OHLC (Open, High, Low, Close) candle data, K-line charts, and price analytics for crypto tokens across all supported blockchains including Ethereum, Solana, BSC, Polygon, and Tron.

Recommendation: Use the Crypto Price API as your main source for OHLC and K-line data—real-time streams and pre-aggregated bars (low-latency, easy to use). When you need full historical OHLC (deep backfill, archive ranges, or candles built from raw DEX trades), use DEXTradeByTokens on EVM or Solana and aggregate trades into candles—see comparison below.

How do I get OHLCV data for a token using Bitquery?

Use the Crypto Price API first (TradingTokens, Pairs, or Currencies): pre-aggregated OHLC, streaming, and intervals such as 1-second and 1-minute, with a clean, multi-DEX index view. For historical OHLC beyond what the Price API covers, switch to DEXTradeByTokens (or chain-specific DEX docs): bucket with Block { Time(interval: { count, in: minutes | hours | days }) } and derive open/high/low/close from PriceInUSD / Trade_Price. See Crypto Price API vs DEXTradeByTokens and the quick table below.

OHLCV & price data — quick answers

QuestionWhere to read / run
How do I get OHLCV data for a token using Bitquery?Last 7 Days Crypto Price API ; historical: DEXTradeByTokens OHLC
How do I get OHLC in a DEXTradeByTokens query?DEXTradeByTokens OHLC (for historical OHLC or DEX-level control)
How do I get historical OHLCV for a Solana token?Main OHLC: Crypto Price API — Quick start · Tokens cube · Historical / DEX: Historical OHLCV on Solana · Solana OHLC API
How do I get the current price of a token using Bitquery API?Quick start · Tokens cube · Examples
How do I get price change percentage for a token?Price change
How do I get 1-minute OHLC candles for a DEX pair?Main: Your first OHLC query (Duration: { eq: 60 }) · Pairs cube · Historical: DEX OHLC pattern
How do I get the all-time high (ATH) price of a token?Solana ATH example
Is there an API to get token price in USD on Solana?Crypto Price API — Quick start · Tokens cube · Latest USD (Solana DEX trades)
How do I use DEXTradeByTokens vs DEXTrades for OHLCV?OHLCV: which cube? · DEXTrades cube

What is OHLC Data?

OHLC (Open, High, Low, Close) data, also known as candlestick or K-line data, is the foundation of technical analysis in cryptocurrency trading. Each OHLC candle represents price movement over a specific time interval:

  • Open: The first price recorded in the interval
  • High: The highest price reached during the interval
  • Low: The lowest price reached during the interval
  • Close: The last price recorded in the interval

Our Crypto Price API provides pre-aggregated OHLC data with ultra-low latency—use it as the main source for live charts and typical OHLC needs.

Historical OHLC: For deep history or candles computed from raw DEX trades, use DEXTradeByTokens on EVM or Solana (with dataset: combined or archive as needed).

Getting Started

Quick Start Steps

  1. Get API Key: Sign up at Bitquery IDE to get your API key
  2. Choose your method
    • GraphQL queries: For one-off APIs
    • WebSocket Streams: For real-time data feeds
    • Kafka: For high-throughput applications with high degree of relibility
  3. Select the Right Cube: Choose between Currency, Tokens, or Pairs based on your needs
  4. Start with Examples: Use our ready-to-run examples below

Your First OHLC Query

Get real-time Bitcoin OHLC data across all chains:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Currencies(
where: {
Currency: { Id: { is: "bid:bitcoin" } },
Interval: { Time: { Duration: { eq: 60 } } },
Volume: { Usd: { gt: 5 } }
}
) {
Currency {
Id
Name
Symbol
}
Price {
Ohlc {
Open
High
Low
Close
}
}
Volume {
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
}
}
}

Run this query ➤

API Endpoints

  • GraphQL Endpoint: https://streaming.bitquery.io/graphql
  • Topic: trading.prices. Please contact sales for a trial username, password.

Why Use Our OHLC API?

Pre-Aggregated Data

  • No need to calculate OHLC from raw trade data
  • Ready-to-use candlestick data for any time interval
  • Optimized for performance and accuracy
  • Uses pre-aggregated price data updated in real-time

Multi-Chain Support

  • Get OHLC data across all major blockchains
  • Chain-agnostic currency views (e.g., Bitcoin across all chains)
  • Cross-chain price aggregation

Real-Time Streaming

  • WebSocket subscriptions for live OHLC updates
  • Kafka streams for high-throughput applications
  • Sub-second latency for trading applications

Advanced Analytics

  • Moving averages (SMA, WMA, EMA)
  • Volume-weighted prices
  • Price change calculations
  • Technical indicators

Crypto Price API vs DEXTradeByToken

Default for OHLC: Use the Crypto Price API as the primary source for real-time and standard OHLC. Use DEXTradeByTokens when you need full historical OHLC or trade-based aggregation over long ranges.

FeatureCrypto Price APIDEXTradeByTokens
Data AvailabilityReal-time + recent OHLC (Price Index)Real-time + full historical (with dataset: combined / archive as supported)
Data ProcessingPre-aggregated and real time aggregation of price dataRaw trades aggregated on-the-fly in your query
Data QualityFiltered, clean price feed, second levelTrade Level Price

When to Use Crypto Price API:

  • Default for OHLC and K-lines—live streaming and pre-aggregated bars
  • Real-time trading applications requiring normalized pricing
  • Live charting and dashboards with aggregated price feeds
  • High-frequency trading strategies with sub-second updates
  • Limit order execution with reliable mark prices
  • Futures trading and derivatives pricing
  • Lending and borrowing protocols requiring accurate rates
  • DeFi applications needing real-time price oracles
  • Any application requiring reliable real-time price streams
  • Fixed time intervals available due to pre-aggregated data

When to Use DEXTradeByTokens API:

  • Historical OHLC and long-range backfills
  • When you need actual per-trade detail not only index OHLC
  • Full price history, custom intervals, or archive-backed ranges
  • Any time interval can be used because aggregation is defined in the query over trades

Supported Time Intervals

Our Crypto Price API OHLC API supports fixed time intervals optimized for different trading strategies:

IntervalDuration
1 second1s
3 seconds3s
5 seconds5s
10 seconds10s
30 seconds30s
1 minute60s
5 minutes300s
15 minutes900s
30 minutes1800s
1 hour3600s

Volume-Based Aggregation

For volume-driven analysis, we also support volume-based intervals:

  • $1,000 USD
  • $10,000 USD
  • $100,000 USD
  • $1,000,000 USD

Choosing the Right Cube for OHLC Data

The Crypto Price API offers three different cubes for accessing OHLC data. Understanding which cube to use is crucial for getting the right data for your specific use case:

Before we dive into the cubes, let's clarify the key terminology:

Currency - The underlying asset (e.g., BTC, ETH, SOL) Token - Specific implementations of a currency on blockchains (e.g., cbBTC, WBTC are Bitcoin tokens) Pair - Trading pairs between two assets (e.g., cbBTC/ETH, WBTC/ETH, WBTC/SOL)

Currency Cube - Chain-Agnostic Aggregated View

Use the Currency cube when you want a unified price view of an asset across all blockchains.

Key Features:

  • Aggregates all token representations of the same underlying asset for example for BTC it will combine multiple tokens like WBTC, cbBTC, LBTC etc.
  • Can provide both chain specific and chain agnostic prices
  • Can provide only USD-quoted prices
  • Can combine volume and price data from all chains

Learn more about Currency Cube ➤

Tokens Cube - Chain-Specific Token Data

Use the Tokens cube when you need OHLC data for a specific token on a specific blockchain.

Key Features:

  • Aggregates across all pairs for that token
  • Can provide both chain specific and chain agnostic prices
  • Can provide only USD-quoted prices
  • Can combine volume and price data from all chains

Learn more about Tokens Cube ➤

Pairs Cube - Trading Pair Specific Data

Use the Pairs cube when you need OHLC data for specific trading pairs on specific DEXs.

Key Features:

  • Pair-specific OHLC data (e.g., ETH/USDC on Uniswap)
  • Can be quoted in USD or quote token
  • Market/DEX-specific data
  • Most granular level of price data

Learn more about Pairs Cube ➤

Real-Time OHLC Stream Examples

1. Live Bitcoin OHLC Across All Chains

Stream real-time Bitcoin OHLC data aggregated from all supported blockchains (Bitcoin, Ethereum WBTC, Solana, etc.) with 60-second intervals:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Currencies(
where: {
Currency: { Id: { is: "bid:bitcoin" } },
Interval: { Time: { Duration: { eq: 60 } } },
Volume: { Usd: { gt: 5 } }
}
) {
Currency {
Id
Name
Symbol
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
BaseAttributedToUsd
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
IsQuotedInUsd
Ohlc {
Open # First price in interval
High # Highest price in interval
Low # Lowest price in interval
Close # Last price in interval
}
Average {
Mean
SimpleMoving
WeightedSimpleMoving
ExponentialMoving
}
}
}
}
}

Run Live Stream ➤

2. Ethereum OHLC on All DEXs

Get real-time Ethereum OHLC data from all decentralized exchanges:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Pairs(
where: {Currency: {Id: {is: "bid:eth"}}, Interval: {Time: {Duration: {eq: 60}}}, Volume: {Usd: {gt: 5}}}
) {
Token {
Symbol
Network
Address
}
QuoteToken {
Symbol
Network
Address
}
Market {
Name
Protocol
Network
Address
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
IsQuotedInUsd
Ohlc {
Open
High
Low
Close
}
Average {
Mean
SimpleMoving
WeightedSimpleMoving
ExponentialMoving
}
}
}
}
}

Run Live Stream ➤

3. Solana Token OHLC Stream

Monitor all Solana tokens with real-time OHLC data:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Tokens(
where: {
Token: { Network: { is: "Solana" } },
Interval: { Time: { Duration: { eq: 60 } } },
Volume: { Usd: { gt: 5 } }
}
) {
Token {
Address
Id
IsNative
Name
Network
Symbol
TokenId
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
IsQuotedInUsd
Ohlc {
Close
High
Low
Open
}
Average {
ExponentialMoving
Mean
SimpleMoving
WeightedSimpleMoving
}
}
}
}
}

Run Live Stream ➤

Historical OHLC Queries

Note: These examples use the Crypto Price API for recent OHLC. For full historical OHLC, use DEXTradeByTokens.

1. Bitcoin OHLC (Crypto Price API)

Recent Bitcoin OHLC using the Crypto Price API (time range in the query matches what the Price Index supports).

Run Query

Note: We include Volume: { Usd: { gt: 5 } } in most examples to remove extreme outliers. The example uses a relative time window in Block.Time.

{
Trading {
Currencies(
where: {
Currency: { Id: { is: "bid:bitcoin" } },
Interval: { Time: { Duration: { eq: 3600 } } },
Volume: { Usd: { gt: 5 } },
Block: {Time:{
since_relative:{days_ago:7}
}}
},
limit: { count: 240 },
orderBy: { descending: Block_Time }
) {
Currency {
Id
Name
Symbol
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
BaseAttributedToUsd
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
IsQuotedInUsd
Ohlc {
Open
High
Low
Close
}
Average {
Mean
SimpleMoving
WeightedSimpleMoving
ExponentialMoving
}
}
}
}
}

2. Top 10 Tokens by 5-Minute Price Change

Find the biggest movers with OHLC data and price change calculations:

Note: We include Volume: { Usd: { gt: 5 } } in most examples to remove extreme outliers; this example already filters by Volume: { Usd: { gt: 100000 } }.

{
Trading {
Tokens(
limit: { count: 10 }
orderBy: { descendingByField: "change" }
where: {
Price: { IsQuotedInUsd: true }
Volume: { Usd: { gt: 100000 } }
Interval: { Time: { Duration: { eq: 300 } } }
}
) {
Token {
Address
Id
IsNative
Name
Network
Symbol
TokenId
}
Currency {
Symbol
Id
Name
}
Interval {
Time {
Start
End
Duration
}
}
Volume {
Base
BaseAttributedToUsd
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
IsQuotedInUsd
Ohlc {
Close
High
Low
Open
}
Average {
Estimate
ExponentialMoving
Mean
SimpleMoving
WeightedSimpleMoving
}
}
diff: calculate(expression: "Price_Ohlc_Close - Price_Ohlc_Open")
change: calculate(expression: "round(($diff / Price_Ohlc_Open), 3) * 100")
}
}
}

Run Query ➤

DEX-Specific OHLC Streams

1. Uniswap v3 OHLC Stream

Monitor all tokens on Uniswap v3 with 1-second OHLC data:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Pairs(
where: {
Interval: { Time: { Duration: { eq: 1 } } },
Price: { IsQuotedInUsd: true },
Market: {
Network: { is: "Ethereum" },
Address: { is: "0x1f98431c8ad98523631ae4a59f267346ea31f984" }
},
Volume: { Usd: { gt: 5 } }
}
) {
Market {
Protocol
Program
Network
Name
Address
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
Ohlc {
Close
High
Low
Open
}
IsQuotedInUsd
}
Currency {
Symbol
Name
Id
}
QuoteCurrency {
Name
Symbol
Id
}
Token {
Name
Symbol
Address
Id
NetworkBid
}
QuoteToken {
Name
Symbol
Id
Address
NetworkBid
}
}
}
}

Run Stream ➤

2. Raydium OHLC Stream (Solana)

Track all tokens on Raydium with real-time OHLC data:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Pairs(
where: {
Interval: { Time: { Duration: { eq: 1 } } },
Price: { IsQuotedInUsd: true },
Market: {
Network: { is: "Solana" },
Program: { is: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8" }
},
Volume: { Usd: { gt: 5 } }
}
) {
Market {
Protocol
Program
Network
Name
Address
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
Ohlc {
Close
High
Low
Open
}
IsQuotedInUsd
}
Currency {
Symbol
Name
Id
}
QuoteCurrency {
Name
Symbol
Id
}
Token {
Name
Symbol
Address
Id
NetworkBid
}
QuoteToken {
Name
Symbol
Id
Address
NetworkBid
}
}
}
}

Run Stream ➤

3. PancakeSwap v3 OHLC Stream (BSC)

Monitor BSC tokens on PancakeSwap v3:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Pairs(
where: {
Interval: { Time: { Duration: { eq: 1 } } },
Price: { IsQuotedInUsd: true },
Market: {
Network: { is: "Binance Smart Chain" },
Address: { is: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865" }
},
Volume: { Usd: { gt: 5 } }
}
) {
Market {
Protocol
Program
Network
Name
Address
}
Block {
Date
Time
Timestamp
}
Interval {
Time {
Start
Duration
End
}
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
Ohlc {
Close
High
Low
Open
}
IsQuotedInUsd
}
Currency {
Symbol
Name
Id
}
QuoteCurrency {
Name
Symbol
Id
}
Token {
Name
Symbol
Address
Id
NetworkBid
}
QuoteToken {
Name
Symbol
Id
Address
NetworkBid
}
}
}
}

Run Stream ➤

Kafka Streaming for OHLC Data

For high-throughput applications, use our Kafka streams to get real-time OHLC data:

Kafka Topic: trading.prices

The Kafka topic delivers real-time, pre-aggregated OHLC data for all supported tokens and currencies.

Schema: Protobuf Schema

Packages:

Kafka Consumer Example (Python)

from kafka import KafkaConsumer
import bitquery_pb2

# Configure Kafka consumer
consumer = KafkaConsumer(
'trading.prices',
bootstrap_servers=['your-kafka-broker:9092'],
value_deserializer=lambda m: bitquery_pb2.PriceIndexMessage().ParseFromString(m)
)

# Consume OHLC data
for message in consumer:
price_data = message.value

# Extract OHLC data
ohlc = price_data.price.ohlc
print(f"Token: {price_data.token.symbol}")
print(f"Open: {ohlc.open}")
print(f"High: {ohlc.high}")
print(f"Low: {ohlc.low}")
print(f"Close: {ohlc.close}")
print(f"Volume: {price_data.volume.usd}")
print("---")

Kafka Consumer Example (Node.js)

const kafka = require('kafkajs');
const { PriceIndexMessage } = require('bitquery-protobuf-schema');

const client = kafka({
clientId: 'ohlc-consumer',
brokers: ['your-kafka-broker:9092']
});

const consumer = client.consumer({ groupId: 'ohlc-group' });

async function run() {
await consumer.connect();
await consumer.subscribe({ topic: 'trading.prices' });

await consumer.run({
eachMessage: async ({ topic, partition, message }) => {
const priceData = PriceIndexMessage.decode(message.value);

// Extract OHLC data
const ohlc = priceData.price.ohlc;
console.log(`Token: ${priceData.token.symbol}`);
console.log(`Open: ${ohlc.open}`);
console.log(`High: ${ohlc.high}`);
console.log(`Low: ${ohlc.low}`);
console.log(`Close: ${ohlc.close}`);
console.log(`Volume: ${priceData.volume.usd}`);
console.log('---');
},
});
}

run().catch(console.error);

TradingView Integration

Our OHLC API is perfect for TradingView charting. Use our ready-to-use SDK:

TradingView SDK

import { BitqueryTradingViewDatafeed } from '@bitquery/tradingview-sdk';

const datafeed = new BitqueryTradingViewDatafeed({
apiKey: 'your-bitquery-api-key',
token: 'BTC', // or any supported token
interval: '1m', // 1m, 5m, 15m, 1h, etc.
});

// Initialize TradingView widget
const widget = new TradingView.widget({
symbol: 'BTC/USD',
interval: '1m',
container: 'tradingview_chart',
datafeed: datafeed,
library_path: '/tradingview/',
locale: 'en',
disabled_features: ['use_localstorage_for_settings'],
enabled_features: ['study_templates'],
charts_storage_url: 'https://saveload.tradingview.com',
charts_storage_api_version: '1.1',
client_id: 'tradingview.com',
user_id: 'public_user_id',
fullscreen: false,
autosize: true,
});

Get TradingView SDK ➤

Advanced OHLC Analytics

1. Price Change Analysis

Calculate percentage price changes using expressions:

{
Trading {
Tokens(
where: {
Price: { IsQuotedInUsd: true },
Volume: { Usd: { gt: 100000 } },
Interval: { Time: { Duration: { eq: 300 } } }
}
) {
Token {
Symbol
Network
}
Price {
Ohlc {
Open
Close
}
}
# Calculate price change percentage
priceChange: calculate(expression: "((Price_Ohlc_Close - Price_Ohlc_Open) / Price_Ohlc_Open) * 100")
# Calculate absolute price change
priceDiff: calculate(expression: "Price_Ohlc_Close - Price_Ohlc_Open")
}
}
}

2. Volume-Weighted OHLC

Get volume-weighted OHLC data for more accurate price representation:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

subscription {
Trading {
Pairs(
where: {
Currency: { Id: { is: "bid:eth" } },
Interval: { Time: { Duration: { eq: 60 } } },
Volume: { Usd: { gt: 5 } }
}
) {
Token {
Symbol
}
Volume {
Base
Quote
Usd
}
Supply {
TotalSupply
FullyDilutedValuationUsd
MarketCap
}
Price {
Ohlc {
Open
High
Low
Close
}
Average {
WeightedSimpleMoving # Volume-weighted average
Mean # Simple average
}
}
}
}
}

3. Cross-Chain Arbitrage Detection

Find arbitrage opportunities using OHLC data across chains:

Note: We include Volume: { Usd: { gt: 5 } } to further remove extreme outliers; the stream already pre-filters outliers—this is an additional check.

{
Trading {
Pairs(
where: {
Currency: { Id: { is: "bid:bitcoin" } },
QuoteCurrency: { Id: { is: "usdt" } },
Volume: { Usd: { gt: 5 } }
},
limit: { count: 10 },
orderBy: { descending: Block_Time },
limitBy: { by: Market_Address, count: 1 }
) {
Currency {
Name
Symbol
}
Market {
Name
Network
Address
}
Price {
Ohlc {
Close
}
Average {
Mean
}
}
QuoteCurrency {
Symbol
}
}
}
}

Run Query ➤

Can I get 1-minute historical OHLC data for a full year?

Crypto Price API: best for live and recent OHLC; an unbroken one-year 1-minute series may exceed what the Price Index is designed to serve—check your plan and try coarser intervals or DEX-derived data for deep history. DEXTradeByTokens: bucket with Time(interval: { count: 1, in: minutes }) and a 365-day Block.Time range; minutes with no trades will be empty or sparse, and the query can be heavy. Prefer hourly/daily bars or export raw trades for backfill. See Historical Solana aggregate data and DEXTradesByTokens OHLC.

Supported Blockchains

Our OHLC API supports all major blockchains:

  • Ethereum - ETH, ERC-20 tokens
  • Solana - SOL, SPL tokens
  • Binance Smart Chain (BSC) - BNB, BEP-20 tokens
  • Polygon - MATIC, ERC-20 tokens
  • Arbitrum - ETH, ERC-20 tokens
  • Optimism - ETH, ERC-20 tokens
  • Base - ETH, ERC-20 tokens
  • Tron - TRX, TRC-20 tokens

API Endpoints

  • GraphQL Endpoint: https://streaming.bitquery.io/graphql
  • Kafka Broker: streaming.bitquery.io:9092
  • Topic: trading.prices

Best Practices

  1. Choose the right API: Use Crypto Price API as the main source for OHLC; use DEXTradeByTokens for historical OHLC from DEX trades
  2. Choose the Right Interval: Use 1s for high-frequency trading, 1m for standard charting
  3. Use USD Quoting: Set IsQuotedInUsd: true for consistent price comparison

Support


Get started with real-time OHLC data today and build the next generation of crypto trading applications.