Skip to main content

Official Python client for the CandleFeed crypto market-data API — OHLCV, funding, open interest, liquidations, basis, options. Returns pandas DataFrames.

Project description

candlefeed

The official Python client for CandleFeed — crypto market data that lands straight in a pandas DataFrame.

OHLCV, funding rates, open interest, liquidations, long/short ratio, taker volume, basis, and Deribit options — across Binance, Bybit, OKX, and more. Auth, cursor pagination, and rate limits are handled for you. One call, one DataFrame.

pip install candlefeed

Time to first DataFrame

from candlefeed import CandleFeed

cf = CandleFeed(api_key="cf_live_...")          # or set CANDLEFEED_API_KEY
df = cf.get_ohlcv("BTCUSDT", interval="1h", limit=5)
print(df)
                              open      high       low     close      volume   quote_volume
time
2026-06-06 18:00:00+00:00  69841.0   70120.5   69770.0   70011.2   1183.42   8.27e+07
2026-06-06 19:00:00+00:00  70011.2   70250.0   69905.1   70180.9   964.18    6.77e+07
...

The frame is indexed by a tz-aware DatetimeIndex and every numeric column is a float — ready for .resample(), .rolling(), or a backtest loop.

Authentication

Pass your key directly or via the environment:

cf = CandleFeed(api_key="cf_live_...")
# or
export CANDLEFEED_API_KEY=cf_live_...
cf = CandleFeed()

Get a key at candlefeed.ai. The free tier covers Binance majors and the last 30 days; Builder/Pro unlock full history, every exchange, and the derived datasets.

Endpoints

Method Data Key params
get_ohlcv / get_candles OHLCV candles symbol, exchange, interval, start, end, limit
get_funding_rates Per-exchange funding symbol, exchange, ...
get_funding_rates_aggregated OI-weighted funding across venues symbol, interval, exchanges
get_open_interest Open interest symbol, exchange, interval
get_liquidations Liquidation events (tick or bucketed) symbol, exchange, side, interval
get_liquidations_aggregated Pre-aggregated liquidation history symbol, exchange, interval
get_long_short_ratio Long/short account ratio symbol, exchange, interval, ratio_type
get_taker_volume Taker buy/sell volume symbol, exchange, ...
get_basis Futures basis / premium symbol, exchange, interval
get_combined Time-aligned multi-dataset frame symbol, interval, fields
get_options Deribit options chain + greeks currency, instrument_name, expiry
symbols / exchanges / datasets / status Metadata

Intervals — OHLCV: 1m 5m 15m 1h 4h 1d · aggregated funding: 1h 4h 1d · open interest: 5m 15m 1h 4h 1d · aggregated liquidations: 4h 6h 8h 12h 1d · basis: 1h 4h.

Date ranges auto-paginate

Ask for a window and the client transparently follows the API's next_cursor until the range is complete, concatenating into one DataFrame:

df = cf.get_funding_rates(
    "BTCUSDT", exchange="binance",
    start="2026-01-01", end="2026-03-01",
)            # many pages → a single tidy frame

Cap the result with max_rows=..., control page size with limit=..., or disable auto-paging entirely with paginate=False to fetch a single page and inspect the cursor yourself.

Multi-exchange, time-aligned

agg = cf.get_funding_rates_aggregated(
    "BTCUSDT", interval="1h",
    exchanges=["binance", "bybit", "okx"],
)
agg[["weighted_funding_rate", "total_oi_usd", "exchange_count"]].tail()
panel = cf.get_combined(
    "BTCUSDT", interval="1h",
    fields=["ohlcv", "funding_rate", "open_interest"],
)   # OHLCV base timeline with funding + OI forward-filled onto each candle

Error handling

Every API error maps to a typed exception carrying the API code and message:

from candlefeed import (
    CandleFeed, AuthenticationError, TierRestrictedError,
    InvalidParameterError, RateLimitError,
)

cf = CandleFeed(api_key="cf_live_...")
try:
    df = cf.get_options(currency="BTC")
except TierRestrictedError as e:
    print(e.message)        # "...requires Pro tier or higher... Upgrade at https://candlefeed.ai/pricing"
except RateLimitError as e:
    print("retry after", e.retry_after, "seconds")
except (AuthenticationError, InvalidParameterError) as e:
    print(e.code, e.message)
Exception HTTP When
AuthenticationError 401 missing / invalid / revoked key
TierRestrictedError 403 symbol, dataset, exchange, or history window above your plan
InvalidParameterError 400 / 422 bad symbol, interval, or timestamp
RateLimitError 429 raised only after the client's bounded backoff retries are exhausted
CandleFeedError base class; network / unexpected errors

On HTTP 429 the client honors Retry-After / X-RateLimit-Reset and retries with exponential backoff before giving up. Remaining-quota headers are exposed on cf.last_rate_limit.

Requirements

Python ≥ 3.9, requests, and pandas. That's the whole dependency surface.

Links

MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

candlefeed-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

candlefeed-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file candlefeed-0.1.0.tar.gz.

File metadata

  • Download URL: candlefeed-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for candlefeed-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0dff7c476b11b12eb49f67ad5a167257297ac4c7a42bf63c0a9ad4cd975c7ba5
MD5 d902a502eb0742ec2be82e78f0492c76
BLAKE2b-256 a6e3566b3841d66754872a7d51845363e55a9c66f97a7e03ba9b5beee2f29665

See more details on using hashes here.

File details

Details for the file candlefeed-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: candlefeed-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for candlefeed-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76fd980b322706458591d01250569d10f0d0585e8c2babfd074d75083356c2fa
MD5 b7b6a0f805cdbee75ea6155a6f6d24e3
BLAKE2b-256 6984c23d5fb5ee8876c0e5736ac4b8d36fa1bce6ef62d6afd435ba1e1e494d10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page