Skip to main content

Python SDK for the 3kk0 unified streaming API

Project description

kk0 SDK

A minimal Python client for the 3kk0 unified WebSocket stream.

Quickstart

from kk0 import Stream
import asyncio

async def main():
    async with Stream("wss://api.3kk0.com/stream") as s:
        await s.subscribe(
            channels=["trades"],
            symbols=["SOL/USDT"],
            exchanges=["binance"],
        )
        async for event in s:
            print(event)

asyncio.run(main())

The broker exposes a single /stream websocket: send a subscribe payload with the filters you care about, and the iterator yields every normalized trade, orderbook, heartbeat, or raw message that matches. Include raw=True in the subscribe call to flow through the raw-connector payload (events arrive with type == "raw" and a payload that mirrors the upstream exchange data). Adjust depth and other filters as needed for your workload.

Binance quickstart (quotes + trades + funding)

python sdk/python/examples/binance_quotes.py \
  --url ws://localhost:8080/stream \
  --symbol BTC/USDT \
  --depth 20 \
  --speed-ms 100

This example uses the SDK to subscribe to Binance trades, order books, funding marks, and price/ticker updates in one request (the SDK maps priceticker automatically). Set --raw to also receive the exchange-native payloads. Use --speed-ms 100 (fast) or --speed-ms 1000 (slower/lower load) to control Binance depth update cadence.

Unified stream schema

Each event received over /stream follows the dataclasses defined in engine/schemas.py. Trade frames (e.g., type == "trade") always include exchange, symbol, ts_event, ts_exchange, price, size, side, and the optional metadata listed there; order book frames carry bids, asks, update_type, depth, sequence, and the derived helpers documented in the same file. Heartbeats carry info, and enabling raw=True adds type == "raw" messages whose payload is built in apps/broker/unified.py to mirror the upstream connector data.

Every exchange connector referenced by the broker (for example engine/connectors/binance.py, engine/connectors/bybit.py, and engine/connectors/hyperliquid.py) normalizes its native JSON into these fields before the broker fans them to clients. Because the SDK simply deserializes whatever JSON the broker sends (Stream.__anext__ just json.loads(...)), you always see the same normalized keys regardless of the exchange you subscribe to.

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

kk0-0.1.6.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

kk0-0.1.6-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file kk0-0.1.6.tar.gz.

File metadata

  • Download URL: kk0-0.1.6.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for kk0-0.1.6.tar.gz
Algorithm Hash digest
SHA256 29911db9274989c5c3a293f97a3fd97f6017fe15400aff1ecb6b74abe84b2113
MD5 3e6a3cd2ff911d1bf3730bf3297d4676
BLAKE2b-256 a52bfbbe7cee45041b47f32c82c3947dd90bc39a4af8ae3edb3c566624a5a7e4

See more details on using hashes here.

File details

Details for the file kk0-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: kk0-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for kk0-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e7c1334d35432f94200e51f30b4ce7fb031130664fd8ae323e8a0eacfc6a8b
MD5 8d7b23a1728954a5919983b0509b2160
BLAKE2b-256 9cf64052479b40707902869666aeaf28bf648ac4c4ba191e1cf840b074995118

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