-
Bitcoin
$116500
1.98% -
Ethereum
$3851
6.94% -
XRP
$3.070
3.95% -
Tether USDt
$1.000
0.04% -
BNB
$774.7
1.77% -
Solana
$171.9
4.66% -
USDC
$1.000
0.01% -
Dogecoin
$0.2142
6.71% -
TRON
$0.3387
1.28% -
Cardano
$0.7678
5.61% -
Sui
$3.747
9.68% -
Hyperliquid
$39.16
3.69% -
Stellar
$0.4157
6.28% -
Chainlink
$17.93
9.21% -
Bitcoin Cash
$578.1
3.28% -
Hedera
$0.2531
5.60% -
Ethena USDe
$1.001
-0.02% -
Avalanche
$22.75
3.82% -
Litecoin
$120.1
3.76% -
UNUS SED LEO
$8.953
-0.37% -
Toncoin
$3.323
4.76% -
Shiba Inu
$0.00001266
4.22% -
Uniswap
$10.13
7.08% -
Polkadot
$3.786
5.09% -
Dai
$1.000
-0.02% -
Monero
$273.0
-5.03% -
Bitget Token
$4.391
1.62% -
Cronos
$0.1480
5.45% -
Pepe
$0.00001091
5.80% -
Ethena
$0.6314
11.93%
How to get historical market data from the Kraken API
The Kraken API provides historical OHLC cryptocurrency data via its public endpoint, requiring no API key but adhering to rate limits of 15 calls per minute.
Aug 07, 2025 at 03:02 pm

Understanding the Kraken API and Its Data Capabilities
The Kraken API is a powerful interface that allows developers and traders to access real-time and historical market data for a wide range of cryptocurrency pairs. To retrieve historical market data, users must interact with the public endpoints provided by Kraken, particularly the OHLC
(Open, High, Low, Close) endpoint. This endpoint returns candlestick data at various time intervals, which is essential for technical analysis, backtesting trading strategies, or building data-driven dashboards. The data includes timestamp, open price, high price, low price, close price, volume weighted average price (VWAP), volume, and the number of trades for each period.
Accessing the API does not require authentication for public data, meaning no API keys are needed to fetch historical prices. However, rate limits apply: Kraken allows up to 15 calls per minute from a single IP address. Exceeding this limit will result in temporary blocking. To ensure consistent access, implement delays between requests or use exponential backoff strategies in your code.
Identifying the Correct Endpoint for Historical Data
The primary endpoint for retrieving historical market data is:
https://api.kraken.com/0/public/OHLC
This endpoint requires two parameters: pair
and interval
. The pair
parameter specifies the trading pair, such as XBT/USD for Bitcoin to US Dollar, or ETH/EUR for Ethereum to Euro. The interval
parameter defines the timeframe for each candlestick and must be one of the following values: 1 (1 minute), 5 (5 minutes), 15 (15 minutes), 30 (30 minutes), 60 (1 hour), 240 (4 hours), 1440 (1 day), 10080 (1 week), or 21600 (1 month).
To request data, construct a URL with these parameters. For example, to get 1-hour OHLC data for Bitcoin/USD:
https://api.kraken.com/0/public/OHLC?pair=XBT/USD&interval=60
The response will be in JSON format, containing an array of OHLC data points and a last
timestamp indicating the most recent data point, which is useful for pagination.
Using Python to Fetch and Parse Kraken OHLC Data
To programmatically retrieve historical data, Python is a popular choice due to its simplicity and powerful libraries. The requests
library handles HTTP calls, while pandas
can structure the data for analysis.
Install the required packages:
pip install requests pandas
Below is a complete script to fetch and parse OHLC data:
import requests
import pandas as pddef get_ohlc_data(pair, interval=60, since=None):
url = "https://api.kraken.com/0/public/OHLC"
params = {'pair': pair, 'interval': interval}
if since:
params['since'] = since
response = requests.get(url, params=params)
data = response.json()
if data['error']:
raise Exception(f"API Error: {data['error']}")
ohlc_data = data['result'][pair]
df = pd.DataFrame(ohlc_data, columns=[
'timestamp', 'open', 'high', 'low', 'close', 'vwap', 'volume', 'count'
])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')
df.set_index('timestamp', inplace=True)
last_timestamp = data['result']['last']
return df, last_timestamp
Example usage
df, last = get_ohlc_data('XBT/USD', interval=60)
print(df.head())
This script returns a pandas DataFrame with properly formatted timestamps and numerical values, making it ready for plotting or analysis. The since
parameter allows fetching data after a specific timestamp, enabling incremental data collection.
Handling Pagination for Extended Historical Data
Kraken limits each API call to 720 data points (e.g., 720 hourly candles = 30 days). To retrieve longer historical series, use the since
parameter iteratively.
- Make the initial request without the
since
parameter - Extract the
last
value from the response - Use this
last
value as thesince
parameter in the next request - Repeat until no new data is returned or the desired date range is covered
Example loop:
all_data = []
last = Nonefor _ in range(5): # Retrieve up to 5 pages
df, last_timestamp = get_ohlc_data('XBT/USD', interval=1440, since=last)
all_data.append(df)
last = last_timestamp
time.sleep(1) # Respect rate limits
full_history = pd.concat(all_data)
This approach ensures complete historical coverage without exceeding rate limits.
Validating and Cleaning Retrieved Data
After fetching data, validation is crucial. Check for missing values, duplicate timestamps, or inconsistent formatting. Use pandas methods:
df.isnull().sum()
to detect missing valuesdf.index.duplicated().any()
to find duplicate timestampsdf.sort_index()
to ensure chronological order
Handle gaps in time series:
full_range = pd.date_range(start=df.index.min(), end=df.index.max(), freq='H')
df = df.reindex(full_range)
This creates a continuous timeline, filling missing periods with NaN, which can later be interpolated or marked as gaps.
Commonly Asked Questions
What trading pairs are supported by the Kraken OHLC endpoint?
Kraken supports a wide variety of pairs, including major cryptocurrencies like XBT/USD, ETH/USD, ADA/EUR, and stablecoin pairs such as USDT/USD. A full list can be obtained by calling the AssetPairs
endpoint: https://api.kraken.com/0/public/AssetPairs
.
Can I get tick-level historical data from Kraken?
No, the public API only provides candlestick (OHLC) data at minimum 1-minute intervals. Tick-level (trade-by-trade) historical data is not available through standard API endpoints. For granular trade data, consider third-party aggregators or commercial data providers.
Why am I getting an empty result or error when calling the OHLC endpoint?
Ensure the pair
parameter uses the correct Kraken symbol format. For example, use XBT/USD, not BTC/USD. Also verify that the interval
value is one of the allowed integers. Network issues or exceeding rate limits can also cause empty responses.
Is there a way to retrieve data in CSV format directly from Kraken?
The Kraken API only returns data in JSON format. You must convert the JSON response to CSV manually using tools like pandas:
df.to_csv('kraken_xbtusd_hourly.csv')
Disclaimer:info@kdj.com
The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!
If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.
- Dogecoin, Crypto, and the 25x Gains Dream: What's Next?
- 2025-08-07 20:50:12
- Dogecoin: A Second Chance for the OG Meme Coin?
- 2025-08-07 20:50:12
- BlockchainFX: Your Choice for Long-Term Crypto Gains?
- 2025-08-07 21:10:12
- Pepe Dollar's Presale Mania: Memecoin Staking and the Crypto Revolution
- 2025-08-07 21:10:12
- Aave Users Targeted in Sophisticated Phishing Scam: A DeFi Reality Check
- 2025-08-07 21:15:56
- Ollama Turbo & GPT-OSS: Revolutionizing AI Model Accessibility and Speed
- 2025-08-07 20:29:33
Related knowledge

How to deposit USD on Bitstamp
Aug 07,2025 at 05:18pm
Understanding Bitstamp and USD DepositsBitstamp is one of the longest-standing cryptocurrency exchanges in the industry, offering users the ability to...

How to set up custom price alerts on Bybit
Aug 07,2025 at 04:31pm
Understanding Price Alerts on BybitPrice alerts on Bybit are essential tools for traders who want to stay informed about significant price movements i...

How to use the API for automated trading on OKX
Aug 07,2025 at 05:21pm
Understanding the OKX API for Automated TradingThe OKX API provides a powerful interface for users to automate their trading strategies, access real-t...

How to claim airdropped tokens on Gate.io
Aug 07,2025 at 04:01pm
Understanding Airdropped Tokens on Gate.ioAirdropped tokens are digital assets distributed for free by blockchain projects to promote awareness, incen...

How to paper trade cryptocurrencies on OKX
Aug 07,2025 at 06:01pm
Understanding Paper Trading in the Cryptocurrency ContextPaper trading, also known as simulated or virtual trading, allows users to practice buying an...

How to whitelist a withdrawal address on Coinbase
Aug 07,2025 at 07:28pm
Understanding Withdrawal Address Whitelisting on CoinbaseWhitelisting a withdrawal address on Coinbase enhances the security of your cryptocurrency ho...

How to deposit USD on Bitstamp
Aug 07,2025 at 05:18pm
Understanding Bitstamp and USD DepositsBitstamp is one of the longest-standing cryptocurrency exchanges in the industry, offering users the ability to...

How to set up custom price alerts on Bybit
Aug 07,2025 at 04:31pm
Understanding Price Alerts on BybitPrice alerts on Bybit are essential tools for traders who want to stay informed about significant price movements i...

How to use the API for automated trading on OKX
Aug 07,2025 at 05:21pm
Understanding the OKX API for Automated TradingThe OKX API provides a powerful interface for users to automate their trading strategies, access real-t...

How to claim airdropped tokens on Gate.io
Aug 07,2025 at 04:01pm
Understanding Airdropped Tokens on Gate.ioAirdropped tokens are digital assets distributed for free by blockchain projects to promote awareness, incen...

How to paper trade cryptocurrencies on OKX
Aug 07,2025 at 06:01pm
Understanding Paper Trading in the Cryptocurrency ContextPaper trading, also known as simulated or virtual trading, allows users to practice buying an...

How to whitelist a withdrawal address on Coinbase
Aug 07,2025 at 07:28pm
Understanding Withdrawal Address Whitelisting on CoinbaseWhitelisting a withdrawal address on Coinbase enhances the security of your cryptocurrency ho...
See all articles
