finance-query v3.0.0

Kraken (public market data)#

info · Feature flag required

toml
finance-query = { version = "...", features = ["kraken"] }

Kraken's public endpoints (api.kraken.com/0/public/*) need no API key and impose no geo-block — which is the reason this provider exists alongside Binance, whose data is richer but unavailable to US retail users.

Two exchanges also give Capability::CRYPTO a real fallback chain:

rust · no_run feature=full
use finance_query::{Capability, Fetch, Provider, Providers};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let providers = Providers::builder()
        .route(Capability::CRYPTO, [Provider::Binance, Provider::Kraken, Provider::CoinGecko])
        .fetch(Fetch::Sequential)
        .build()
        .await?;
    Ok(())
}

Capabilities#

CapabilityWhat Kraken serves
CRYPTO24-hour ticker per spot pair
CHARTOHLC candles
rust · no_run feature=kraken
use finance_query::{Capability, Provider, Providers};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let providers = Providers::builder()
        .route(Capability::CRYPTO, [Provider::Kraken])
        .build()
        .await?;

    let btc = providers.crypto("bitcoin");
    let quote = btc.quote("usd").await?;
    println!("BTC {:?}", quote.price);
    Ok(())
}

Kraken's Own Symbol Conventions#

Kraken predates most ticker conventions and kept its own:

Everyone elseKraken
BTCXBT
DOGEXDG
BTC/USDXXBTZUSD (legacy X/Z asset-class prefixes)

None of that reaches your call sites. Pass normal tickers, coin ids, or separated pairs and the adapter translates in both directions:

You passKraken pair
crypto("bitcoin").quote("usd")XBTUSD
crypto("DOGE").quote("eur")XDGEUR
chart symbol BTC-USDXBTUSD
chart symbol SOLUSDSOLUSD

Kraken also answers with a pair name that differs from the one requested (XBTUSD comes back keyed as XXBTZUSD), so the adapter reads the response positionally rather than looking up the name it sent.

Response Notes#

CryptoQuote:

Chart:

Intervals and History Depth#

Every library interval maps to a Kraken bucket except ThreeMonths, which returns NotSupported so sequential routing falls through. OneMonth maps to Kraken's longest bucket, 15 days.

warning · Roughly 720 candles maximum

Kraken's /OHLC endpoint returns at most ~720 candles ending at the present, and its since parameter only moves the window's start forward — there is no way to page further back. A range wider than 720 candles returns the most recent 720, not the full window. For deep history, route CHART to Binance (which is paged automatically) or to a keyed provider.

Errors#

Kraken answers a rejected request with HTTP 200 and a populated error array, so the status code alone never means success. An unknown pair surfaces as FinanceError::SymbolNotFound; anything else carries Kraken's own error text.

Rate Limits#

Kraken's public counter allows roughly one call per second sustained for unauthenticated clients, and the client paces to match. That is deliberately slower than the Binance adapter — put Binance first in a chain if throughput matters and your region allows it.

Next Steps#

built with cargo soothfast docs build source