Python asyncio client for Kraken API REST and Kraken Websockets API using httpx and websockets
Project description
Kraky
Python asyncio client for Kraken API REST and Kraken Websockets API using httpx and websockets
Installation
pip install kraky
Usage
REST
from kraky import KrakyApiClient
async def get_token():
kraken_api_key = ""
kraken_secret = ""
kraky_api_client = KrakyApiClient(
api_key=kraken_api_key, secret=kraken_secret
)
ws_token = await self.kraky_api_client.get_ws_token()
return ws_token
Websocket
from kraky import KrakyWsClient
async def public_handler(self, response):
print(response)
async def private_handler(self, response):
print(response)
async def main():
interval = 30
ws_pairs = ["XBT/USD", "ETH/USD]
ws_token = get_token()
kraky_public_ws_client = KrakyWsClient("production")
kraky_private_ws_client = KrakyWsClient("production-auth")
asyncio.create_task(
kraky_public_ws_client.connect(
public_handler, connection_name="public"
)
)
asyncio.create_task(
kraky_private_ws_client.connect(
private_handler, connection_name="private"
)
)
await kraky_public_ws_client.subscribe(
{"name": "ohlc", "interval": interval},
ws_pairs,
connection_name="public",
)
await kraky_private_ws_client.subscribe(
{
"interval": interval,
"token": ws_token,
"name": "openOrders",
},
connection_name="private",
)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
Compatibility
- Python 3.7 and above
Licence
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kraky-0.1.1.tar.gz
(3.9 kB
view details)
Built Distribution
kraky-0.1.1-py3-none-any.whl
(5.1 kB
view details)
File details
Details for the file kraky-0.1.1.tar.gz
.
File metadata
- Download URL: kraky-0.1.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47bd0fad1b000ea1e9300efe91047bac038553ab409dfc714df37152cf6eff9a |
|
MD5 | 6a3abbf73180727e8f61af5cb2f7e72f |
|
BLAKE2b-256 | 3ce0b28a2b514375bced70598ee1881b7f42914b0401fae703b25b1d23bfd9b6 |
File details
Details for the file kraky-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: kraky-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbf517c406c6f34c9a1a57686249b9e775cc479dfe576bd13a6bfc4d8fd68e94 |
|
MD5 | 4fb01f4784e4cf75b34b2cf7efc05e73 |
|
BLAKE2b-256 | ad347946a03c2299417f8ff4f06d195214fc53fc407b7e45ae8325f435608423 |