Skip to main content

KadePy

High-Performance P2P Swarm Implementation via Official Hyperswarm Bindings

KadePy is a robust and efficient library for connecting to the Hyperswarm network. It leverages the official, battle-tested Hyperswarm stack (Node.js) through a high-performance native binding, ensuring 100% protocol compliance, reliable holepunching, and secure communications.

Features

  • Official Hyperswarm Stack: Powered by hyperswarm, hyperdht, dht-rpc, and libudx.
  • Full Compatibility: Guaranteed wire compatibility with any Hyperswarm peer (Node.js, Holepunch, etc.).
  • Native Bindings:
    • Uses a lightweight, managed Node.js daemon for protocol handling.
    • Transparent IPC bridge for high-performance communication between Python and the swarm.
  • Secure:
    • Noise Handshake (XX Pattern): Authenticated, encrypted connections using libsodium (Ed25519/Curve25519).
    • UDX Transport: Reliable, congestion-controlled UDP transport.
  • Easy to Use: Simple Python API for joining topics, finding peers, and exchanging data.
  • Zero-Config: Automatically handles dependency management and process lifecycle.

Installation

Requirements

  • Python 3.10+
  • Node.js & npm (Required for the underlying native bindings)

From Source

git clone https://github.com/ON00dev/KadePy.git
cd KadePy
pip install .

Quick Start

Basic Swarm Node

from kadepy import Swarm
import hashlib
import time

# Create a node (automatically initializes the native backend)
node = Swarm()
print("Node started!")

# Generate a topic key (32-byte hex string or bytes)
topic = hashlib.sha256(b"my-app-topic").digest().hex()
print(f"Joining topic: {topic}")

# Join the swarm for this topic
node.join(topic)

# Define callback for new connections
def on_connection(socket, info):
    print(f"New connection! Peer Key: {info.get('publicKey')}")
    
    # Send a greeting
    socket.sendall(b"Hello from KadePy!")
    
    # Receive data in a loop (simple example)
    while True:
        data = socket.recv(1024)
        if not data: break
        print(f"Received: {data.decode()}")

# Register the callback
node.on("connection", on_connection)

# Keep the process alive
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Stopping...")
    node.close()

Architecture

KadePy v0.3.0 adopts a "Native Binding" architecture:

  1. Python Frontend: Provides the idiomatic Swarm class and event handling.
  2. Native Daemon: A pinned, vendored version of the official Hyperswarm stack running as a managed subprocess.
  3. IPC Bridge: High-speed local TCP bridge for stream piping, allowing Python to interact with raw UDX streams as if they were local sockets.

This architecture ensures that KadePy behaves exactly like a native Node.js Hyperswarm peer on the network layer, eliminating protocol drift and implementation bugs.

Contributing

Contributions are welcome! Please check out the CONTRIBUTING.md guide for details.

License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for kadepy 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kadepy 0.3.0
File Size Uploaded
kadepy-0.3.0.tar.gz 4.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for kadepy 0.3.0
File Interpreter ABI Platform
kadepy-0.3.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details

Total release size: 4.4 MB

Release files / kadepy-0.3.0.tar.gz

Download URL kadepy-0.3.0.tar.gz
Size 4.2 MB
Tags Source
SHA-256 checksum
How to use checksums
5f1e635de72524b2412d442dfed47a8c714c1c7594a948f1c85eb747ab1cf203
BLAKE2b-256 checksum
How to use checksums
c681b27dba3a5de951ad4420b65d7cc5000404e43dac44d9ff7bfbc878a790d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / kadepy-0.3.0-cp314-cp314-win_amd64.whl

Download URL kadepy-0.3.0-cp314-cp314-win_amd64.whl
Size 242.5 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
6f3e836bd8a73f12a85e3ea6afad6807ab216efc63e273b9b268160130e36aef
BLAKE2b-256 checksum
How to use checksums
3688e32bd30236a844c77a475992f0c6d94786dd0d7a29f07a30d722490fcb3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

1 release file

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page