-
bitcoin $87959.907984 USD
1.34% -
ethereum $2920.497338 USD
3.04% -
tether $0.999775 USD
0.00% -
xrp $2.237324 USD
8.12% -
bnb $860.243768 USD
0.90% -
solana $138.089498 USD
5.43% -
usd-coin $0.999807 USD
0.01% -
tron $0.272801 USD
-1.53% -
dogecoin $0.150904 USD
2.96% -
cardano $0.421635 USD
1.97% -
hyperliquid $32.152445 USD
2.23% -
bitcoin-cash $533.301069 USD
-1.94% -
chainlink $12.953417 USD
2.68% -
unus-sed-leo $9.535951 USD
0.73% -
zcash $521.483386 USD
-2.87%
How can I get historical contract data from the Kraken API?
Fetch Kraken Futures historical OHLC data via `futures-api.kraken.com/api/history/candles` using symbol, interval, and Unix timestamps; authenticate with API key and HMAC-SHA256 signature if rate-limited.
Aug 08, 2025 at 02:49 pm
Understanding Kraken API and Historical Contract Data
The Kraken API is a powerful interface that enables developers and traders to interact with Kraken’s cryptocurrency exchange services programmatically. When referring to historical contract data, it's important to clarify that Kraken primarily supports spot trading and futures contracts through its Kraken Futures platform (formerly known as Cryptowatch Derivatives). The standard Kraken REST API (api.kraken.com) does not provide historical data for futures or perpetual contracts directly. Instead, historical contract data is accessible via the Kraken Futures API, hosted at futures-api.kraken.com.
To retrieve historical data, you must identify the correct endpoint based on the type of contract and time frame needed. The Kraken Futures API offers endpoints such as /api/history/candles to fetch OHLC (Open, High, Low, Close) data for specific futures contracts. Each endpoint requires parameters like symbol, interval, and from/until timestamps to define the data range.
Setting Up API Access Credentials
Before making any requests, you must set up authenticated access to the Kraken Futures API. This involves creating an API key and secret:
- Log in to your Kraken account and navigate to the Funding section.
- Select API and choose Kraken Futures.
- Click Create API Key.
- Assign permissions—ensure Read access is enabled for market data.
- Generate the key and securely store both the API key and secret key.
These credentials are required to sign requests using HMAC-SHA256. Unlike spot trading, Kraken Futures uses a separate authentication mechanism. Every request must include headers such as APIKey and Authent, where Authent is the computed signature based on the request method, path, body, and timestamp.
Constructing the API Request for Historical Data
To retrieve historical contract data, use the candles history endpoint:
GET https://futures-api.kraken.com/api/history/candlesRequired query parameters include:
- symbol: The contract symbol, such as
PI_XBTUSDfor the Bitcoin perpetual inverse contract. - interval: The candlestick interval. Valid values include
1m,5m,15m,1h,4h,1d. - from: Start time in Unix timestamp (seconds).
- until: End time in Unix timestamp (seconds).
For example, to fetch 1-hour candles for the Bitcoin perpetual contract from January 1, 2024, to January 2, 2024:
https://futures-api.kraken.com/api/history/candles?symbol=PI_XBTUSD&interval=1h&from=1704067200&until=1704153600This request does not require authentication if only public market data is accessed. However, if rate-limited, consider using authenticated requests.
Handling Authentication for Rate-Limited Requests
If you exceed the unauthenticated request limit, switch to signed requests. The process involves:
- Creating a request payload with method, path, body, and ISO 8601 timestamp.
- Concatenating the timestamp, method, path, and body (if present) into a signing string.
- Using HMAC-SHA256 with your secret key to generate a signature.
- Including the signature in the
Authentheader and your key inAPIKey.
Example steps in Python:
- Set the request method:
GET - Define the path:
/api/history/candles?symbol=PI_XBTUSD&interval=1h&from=1704067200&until=1704153600 - Generate the ISO timestamp:
2024-01-01T00:00:00Z - Build the signing message:
2024-01-01T00:00:00ZGET/api/history/candles?symbol=PI_XBTUSD&interval=1h&from=1704067200&until=1704153600 - Compute HMAC-SHA256 of the message using your secret key
- Encode the result in base64
- Set headers:
APIKey: YOUR_PUBLIC_KEYAuthent: BASE64_SIGNATURENonce: 2024-01-01T00:00:00Z
Send the request using a library like requests.
Processing and Storing the Response Data
The API returns a JSON response containing an array of candle objects. Each candle includes:
- timestamp: Unix time of the candle start.
- open: Opening price.
- high: Highest price.
- low: Lowest price.
- close: Closing price.
- volume: Traded volume.
Example response:
{ 'result': 'success', 'candles': [
{
'timestamp': 1704067200,
'open': '42000.00',
'high': '42500.00',
'low': '41800.00',
'close': '42300.00',
'volume': '120.5'
}
]}
Parse the JSON and extract the candles array. You can store this data in CSV, a database, or a DataFrame for analysis. Ensure timestamps are converted to local time or UTC as needed. Handle pagination if the time range is large—Kraken may limit results per request, requiring multiple calls with adjusted from and until values.
Common Errors and Troubleshooting
- Invalid symbol: Double-check the contract symbol. Use
GET /api/instrumentsto list all available contracts. - Rate limiting: Unauthenticated requests are limited. Use authentication or add delays between calls.
- Invalid timestamp format: Ensure Unix timestamps are in seconds, not milliseconds.
- Signature mismatch: Verify the signing string includes the exact path and query parameters, and that the secret key is correct.
- Empty response: Confirm the time range includes active trading periods.
Use tools like Postman or Python scripts to test requests incrementally. Enable logging to capture request headers and responses for debugging.
Frequently Asked Questions
How do I find the correct symbol for a Kraken Futures contract?Use the instruments endpoint: GET https://futures-api.kraken.com/api/instruments. This returns all active contracts with their symbols, such as PI_XBTUSD for Bitcoin perpetuals or FI_ETHUSD for Ether futures.
Can I retrieve tick-level historical data instead of candles?The Kraken Futures API does not provide tick-level data through public endpoints. The /api/history/candles endpoint only supports aggregated OHLC data at specified intervals. For granular data, consider WebSocket feeds or third-party data providers.
Is there a limit on how much historical data I can fetch at once?Yes, the API may limit the number of candles returned per request. If your time range is large, split it into smaller intervals—such as one day at a time—and make multiple requests. Check the response for completeness and adjust the from and until parameters accordingly.
Do I need to be a verified Kraken user to access historical contract data?For unauthenticated public data requests, basic account access suffices. However, to increase rate limits and ensure stable access, a verified account with API credentials is recommended. Full trading permissions are not required for data retrieval.
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.
- Big Apple Bit: Bitcoin's Rebound Hides a Deeper Dive, Say Wave 3 Watchers
- 2026-02-04 07:00:03
- DeFi Vaults Poised for 2026 Boom: Infrastructure Matures, Yield Optimization and Liquidity Preferences Shape the Future
- 2026-02-04 06:50:01
- Royal Canadian Mint Unveils 'Gold Dime' with Astounding High Value, Captivating Collectors
- 2026-02-04 06:55:01
- Datavault AI Dives into Digital Collectibles with Dream Bowl Meme Coin II, Navigating the Wild West of Web3
- 2026-02-04 06:30:02
- New VistaShares ETF Merges Bitcoin and Treasuries for Enhanced Income
- 2026-02-04 06:55:01
- Epstein's Bitcoin Bet: Newly Uncovered Statements Detail Dark Figure's Early Crypto Foray
- 2026-02-04 06:40:02
Related knowledge
How to close a crypto contract position manually or automatically?
Feb 01,2026 at 11:19pm
Manual Position Closure Process1. Log into the trading platform where the contract is active and navigate to the 'Positions' or 'Open Orders' tab. 2. ...
How to understand the impact of Bitcoin ETFs on crypto contracts?
Feb 01,2026 at 04:19pm
Bitcoin ETFs and Market Liquidity1. Bitcoin ETFs introduce institutional capital directly into the spot market, increasing order book depth and reduci...
How to trade DeFi contracts during the current liquidity surge?
Feb 01,2026 at 07:00am
Understanding Liquidity Dynamics in DeFi Protocols1. Liquidity surges in DeFi are often triggered by coordinated capital inflows from yield farming in...
How to use social trading to copy crypto contract experts?
Feb 02,2026 at 07:40am
Understanding Social Trading Platforms1. Social trading platforms integrate real-time market data with user interaction features, enabling traders to ...
How to trade BNB contracts and save on transaction fees?
Feb 03,2026 at 12:39am
Understanding BNB Contract Trading Mechanics1. BNB contracts are derivative instruments traded on Binance Futures, allowing users to gain leveraged ex...
How to build a consistent crypto contract trading plan for 2026?
Feb 02,2026 at 10:59pm
Defining Contract Specifications1. Selecting the underlying asset requires evaluating liquidity depth, historical volatility, and exchange support acr...
How to close a crypto contract position manually or automatically?
Feb 01,2026 at 11:19pm
Manual Position Closure Process1. Log into the trading platform where the contract is active and navigate to the 'Positions' or 'Open Orders' tab. 2. ...
How to understand the impact of Bitcoin ETFs on crypto contracts?
Feb 01,2026 at 04:19pm
Bitcoin ETFs and Market Liquidity1. Bitcoin ETFs introduce institutional capital directly into the spot market, increasing order book depth and reduci...
How to trade DeFi contracts during the current liquidity surge?
Feb 01,2026 at 07:00am
Understanding Liquidity Dynamics in DeFi Protocols1. Liquidity surges in DeFi are often triggered by coordinated capital inflows from yield farming in...
How to use social trading to copy crypto contract experts?
Feb 02,2026 at 07:40am
Understanding Social Trading Platforms1. Social trading platforms integrate real-time market data with user interaction features, enabling traders to ...
How to trade BNB contracts and save on transaction fees?
Feb 03,2026 at 12:39am
Understanding BNB Contract Trading Mechanics1. BNB contracts are derivative instruments traded on Binance Futures, allowing users to gain leveraged ex...
How to build a consistent crypto contract trading plan for 2026?
Feb 02,2026 at 10:59pm
Defining Contract Specifications1. Selecting the underlying asset requires evaluating liquidity depth, historical volatility, and exchange support acr...
See all articles














