kraken-connector
A typed Python client for the Kraken cryptocurrency exchange, covering both the REST API and WebSocket API v2. Built on httpx for HTTP, websockets for streaming, and attrs for data models.
Features
- REST API -- typed request/response models across 7 endpoint groups (market data, account data, trading, funding, earn, subaccounts, websocket auth)
- WebSocket v2 -- async client with typed channel models for ticker, OHLC, trades, order book, executions, and balances
- Trading -- all 8 WS v2 trading methods (add, edit, cancel, batch add, batch cancel, cancel all, cancel all after, amend)
- Order book management -- local order book state with incremental updates and CRC32 checksum validation
- Automatic reconnection -- configurable backoff with subscription and sequence tracking across reconnects
- Rate limiting -- caller-controlled token-bucket limiter matching Kraken's tier-based rate limits
- Retry -- configurable retry transport with exponential backoff for transient network errors
- Request logging -- optional request/response logging via Python's stdlib
logging - Fully typed --
py.typedmarker, strict mypy, attrs-based models withto_dict()/from_dict()
Requirements
Python 3.11+
Installation
pip install kraken-connector
Quick Start
REST API
from kraken_connector import HTTPClient
from kraken_connector.api.market_data import get_server_time
client = HTTPClient("https://api.kraken.com")
response = get_server_time.sync(client=client)
print(response)
WebSocket
import asyncio
from kraken_connector.ws import KrakenWSClient
from kraken_connector.ws.subscribe import TickerParams
from kraken_connector.ws.envelopes import WSDataMessage
async def main():
async with KrakenWSClient() as client:
await client.subscribe(TickerParams(symbol=["BTC/USD"]))
async for msg in client:
if isinstance(msg, WSDataMessage) and msg.channel == "ticker":
print(msg.data)
asyncio.run(main())
See the documentation for guides on authentication, rate limiting, trading, order book management, error handling, and more.
Development
See CONTRIBUTING.md for development setup and guidelines.
License
Metadata
Release files for kraken_connector 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kraken_connector-0.2.0.tar.gz | 151.5 kB | Without provenance | Details for kraken_connector-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kraken_connector-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for kraken_connector-0.2.0-py3-none-any.whl |
Total release size: 467.8 kB
Release files / kraken_connector-0.2.0.tar.gz
| Download URL | kraken_connector-0.2.0.tar.gz |
|---|---|
| Size | 151.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cdb4c3c03bb11f584fa5fd0144c9fe7ae527ab0343c71826565945f0c47d030
|
|
BLAKE2b-256 checksum How to use checksums |
2702297b3a2c57a5fff9133f9cc81c8e323b4d21dce3fce81ca3a8e59dddb61c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.9 CPython/3.11.15 Linux/6.17.0-1013-azure
|
Release files / kraken_connector-0.2.0-py3-none-any.whl
| Download URL | kraken_connector-0.2.0-py3-none-any.whl |
|---|---|
| Size | 316.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d20a2037554c9fb2b830f953a79005f24c791266eaa45b4a98a3bc461a049f73
|
|
BLAKE2b-256 checksum How to use checksums |
f4401a05f093ccf7ea4839c5a62686dac9cfdffa2eff7390bd1c1dd5bad4366c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.26.9 CPython/3.11.15 Linux/6.17.0-1013-azure
|
Security for kraken_connector 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.