Metadata-Version: 2.4
Name: k256-sdk
Version: 0.1.0
Summary: Official Python SDK for K256 - the gateway to Solana's liquidity ecosystem
Project-URL: Homepage, https://k256.xyz
Project-URL: Documentation, https://docs.k256.xyz
Project-URL: Repository, https://github.com/k256-xyz/k256-sdks
Project-URL: Issues, https://github.com/k256-xyz/k256-sdks/issues
Project-URL: Changelog, https://github.com/k256-xyz/k256-sdks/releases
Author-email: K256 <support@k256.xyz>
Maintainer-email: K256 <support@k256.xyz>
License: MIT
License-File: LICENSE
Keywords: aggregator,blockchain,cryptocurrency,defi,dex,k256,solana,swap,trading,websocket
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: aiohttp>=3.9
Requires-Dist: pydantic>=2.0
Requires-Dist: websockets>=12.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.2; extra == 'dev'
Description-Content-Type: text/markdown

# K256 Python SDK

Official Python SDK for [K256](https://k256.xyz) - the gateway to decentralized finance.

Connect any application to Solana's liquidity ecosystem. One API. All venues. Full observability.

[![PyPI version](https://badge.fury.io/py/k256-sdk.svg)](https://badge.fury.io/py/k256-sdk)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
pip install k256-sdk
```

## Quick Start

```python
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:

```bash
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](../ARCHITECTURE.md).

## License

MIT
