Official Python SDK for K256 - the gateway to Solana's liquidity ecosystem
Project description
K256 Python SDK
Official Python SDK for K256 - the gateway to decentralized finance.
Connect any application to Solana's liquidity ecosystem. One API. All venues. Full observability.
Installation
pip install k256-sdk
Quick Start
import asyncio
from k256 import K256WebSocketClient
async def main():
# Create WebSocket client
client = K256WebSocketClient(api_key="your-api-key")
# Handle pool updates
@client.on_pool_update
def handle_pool(update):
print(f"Pool {update.pool_address}: slot={update.slot}")
print(f" Balances: {update.token_balances}")
# Handle priority fees
@client.on_priority_fees
def handle_fees(fees):
print(f"Recommended fee: {fees.recommended} microlamports")
print(f"Network state: {fees.state}")
# Handle errors
@client.on_error
def handle_error(error):
print(f"Error: {error}")
# Connect and subscribe
await client.connect()
client.subscribe(
channels=["pools", "priority_fees", "blockhash"],
)
# Keep running
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())
Examples
See the examples/ directory for runnable examples:
cd examples
K256_API_KEY=your-key python websocket.py
Module Structure
k256/
├── __init__.py # Main package exports
├── ws/
│ ├── __init__.py
│ ├── client.py # WebSocket client
│ └── decoder.py # Binary message decoder
├── types/
│ ├── __init__.py
│ ├── pool.py # PoolUpdate
│ ├── fees.py # PriorityFees
│ ├── blockhash.py # Blockhash
│ ├── quote.py # Quote
│ ├── token.py # Token
│ ├── heartbeat.py # Heartbeat
│ └── messages.py # MessageType, NetworkState
└── utils/
├── __init__.py
└── base58.py # Base58 encoding
Architecture
This SDK follows the cross-language conventions defined in ARCHITECTURE.md.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k256_sdk-0.1.0.tar.gz.
File metadata
- Download URL: k256_sdk-0.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49b627814422f3ca9b04c94bd83518bbc2c74317424b29b0163135f94de9bd57
|
|
| MD5 |
8f635e89c1d0b02449ad9344f2cc71e8
|
|
| BLAKE2b-256 |
fc409850039843d771fb7573bd73aa71c9c877efac110eb00ff9d67d335768bd
|
File details
Details for the file k256_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: k256_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d5ac38cc6fccab005cacd2a77d02757019e22ef0739bf42678e2eaa0b2e9e33
|
|
| MD5 |
6ec831b611406aeef8fae58cac3a9ccd
|
|
| BLAKE2b-256 |
f6d4d4924e51dcedba2c07b0b7548b5f0582ec2de5cc2505c777b9bedb09a283
|