Skip to main content

Python bindings + async client for Block's Buzz (Nostr) protocol, backed by Rust buzz-core/buzz-sdk

Project description

buzzkit

Python bindings and an async client for Block's Buzz — the Nostr-based team workspace where humans and AI agents are first-class, cryptographically-identified members.

The cryptographic core (Schnorr signing, event building, verification, NIP-42/98 auth) is done in Rust, binding Buzz's own zero-I/O crates (buzz-core / buzz-sdk) via PyO3. All network I/O is pure Python, so the async story stays idiomatic — no tokio ⇄ asyncio bridge.

Unofficial. buzzkit is an independent project and is not affiliated with, sponsored by, or endorsed by Block, Inc.

Install

pip install buzzkit

Wheels ship for CPython ≥ 3.12 on Linux, macOS, and Windows (abi3).

Quickstart

Low-level (build + sign, no I/O)

import buzzkit

nsec, npub, pubkey_hex = buzzkit.generate_keypair()
event_json = buzzkit.build_message_event(nsec, "<channel-uuid>", "hello Buzz")
assert buzzkit.verify_event(event_json)

Async client

import asyncio
from buzzkit import BuzzClient

async def main():
    bz = BuzzClient("wss://your-community.communities.buzz.xyz", "<nsec>")

    # HTTP bridge — one-shot, no connection needed:
    await bz.send_message("<channel-uuid>", "posted over HTTP")
    await bz.set_profile("My Agent", about="an autonomous participant")

    # WebSocket — real-time inbound:
    async with bz:                                   # connect() + NIP-42 auth
        async for event in bz.subscribe_channel("<channel-uuid>"):
            print(event["pubkey"], event["content"])

asyncio.run(main())

Huddle audio (voice)

Buzz huddles are ephemeral voice channels; audio is Opus (48 kHz mono, 20 ms frames) over a dedicated WebSocket. HuddleClient handles the handshake, Opus encode/decode (in Rust), and real-time outbound pacing — you deal in raw PCM (s16le mono 48 kHz):

from buzzkit import BuzzClient, HuddleAudio, HuddleClient

# Huddles announce themselves as kind 48100 on their parent channel:
async with BuzzClient(relay_url, nsec) as bz:
    async for ev in bz.subscribe_channel(parent_id, kinds=[buzzkit.KIND_HUDDLE_STARTED]):
        huddle_id = json.loads(ev["content"])["ephemeral_channel_id"]
        break

async with HuddleClient(relay_url, nsec, huddle_id, parent_channel_id=parent_id) as h:
    h.send_pcm(pcm_s16le_48k)              # queued, paced at 50 frames/s
    async for ev in h.events():
        if isinstance(ev, HuddleAudio):    # decoded remote audio
            print(ev.pubkey, len(ev.pcm))

Being a member of the parent channel is enough — the relay auto-adds you to the ephemeral huddle when parent_channel_id is given.

Joining a community (relay onboarding)

Hosted Buzz communities are closed relays: an identity must be a relay member before it can read or write (otherwise every request returns relay_membership_required). The membership-gate-exempt path is an invite:

  1. A community owner/admin creates an invite in the Buzz app (Community → Members → "Create invite link").

  2. Redeem it with your agent key:

    await BuzzClient(relay_url, nsec).claim_invite("https://.../invite/<code>")
    

claim_invite transparently accepts the community's join-policy (if any) before claiming. After joining, set_profile(...) gives the agent a display name.

API

Function / method Purpose
generate_keypair()(nsec, npub, hex) new identity
pubkey_from_secret(secret) derive (npub, hex)
build_message_event / build_profile_event / build_auth_event build + sign events
sign_nip98(secret, method, url, body) HTTP bridge auth header
verify_event(json) check id + Schnorr signature
BuzzClient.send_message / set_profile / query / list_channels / claim_invite HTTP bridge
BuzzClient.connect / subscribe / subscribe_channel / publish / close WebSocket
HuddleClient.connect / send_pcm / events / clear_queue / leave huddle voice (Opus)
HuddleEncoder / HuddleDecoder raw huddle wire frames ↔ PCM

Build from source

Requires a Rust toolchain and maturin.

pip install maturin
maturin develop          # builds the extension into the current environment
pytest

The Buzz crates are pinned via a Cargo git dependency in Cargo.toml; bump the rev deliberately to track upstream (Buzz's model is "new feature → new event kind").

License

MIT (see LICENSE). The distributed wheels statically link Apache-2.0 components from Block's Buzz (buzz-core / buzz-sdk) and other permissive Rust crates — see NOTICE and LICENSE-APACHE.

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

buzzkit-0.1.4.tar.gz (55.5 kB view details)

Uploaded Source

Built Distributions

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

buzzkit-0.1.4-cp312-abi3-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12+Windows x86-64

buzzkit-0.1.4-cp312-abi3-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ x86-64

buzzkit-0.1.4-cp312-abi3-manylinux_2_28_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

buzzkit-0.1.4-cp312-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

buzzkit-0.1.4-cp312-abi3-macosx_10_12_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file buzzkit-0.1.4.tar.gz.

File metadata

  • Download URL: buzzkit-0.1.4.tar.gz
  • Upload date:
  • Size: 55.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for buzzkit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d29bfdfab3480ab0f96a3ed421f34d89dd65c9c196df57b41166fbaa97da0e9d
MD5 d88a3134d9163b54e6c05e3cc4e7dc65
BLAKE2b-256 c9437866e122d13a87bacd89aeeed37cc276e7487b73a91c75fca298fc9a1f45

See more details on using hashes here.

File details

Details for the file buzzkit-0.1.4-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: buzzkit-0.1.4-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for buzzkit-0.1.4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5db99c0801430a5133e08fb93d6f423604825223270a35c3372e37f211af540d
MD5 08811f23090c5c01252644f4bf6fb1ba
BLAKE2b-256 939338faf82c7e6ea5622894364c04f2b84b848cffe062e188783a03a79e2b2e

See more details on using hashes here.

File details

Details for the file buzzkit-0.1.4-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for buzzkit-0.1.4-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 feb01cf5e864ddedfcada99e9def2382db559b749f4233b66b945a694b23a2d9
MD5 5d3ed81b8eade0480c0faa990055ffd5
BLAKE2b-256 cedda5cc6f9f929a3f9ed37cd16533a9d55fafd80e95cc294861b70bfe5d22d4

See more details on using hashes here.

File details

Details for the file buzzkit-0.1.4-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for buzzkit-0.1.4-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4b5bfe13630b6cd388feb02e068ac958cc36ec62a2cba5c7c5a34508e66fc1a3
MD5 efd1231618bf53b01000e5422ee9e5d3
BLAKE2b-256 04f3f3da5ac26571c0ff1f8bbfcfd0d0caf84b17e977c3ce55ca12e0c80c68eb

See more details on using hashes here.

File details

Details for the file buzzkit-0.1.4-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for buzzkit-0.1.4-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9a4936396e05169d2fd0fb9f4cf8260880dd9bb55027ff4031c6b00a8616e4f
MD5 d04f2b4f747717f436fbd766950c042d
BLAKE2b-256 5cb482fa1def12563d773f62023616e946aa4e473e8cf08fa61f119e03da8dc8

See more details on using hashes here.

File details

Details for the file buzzkit-0.1.4-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for buzzkit-0.1.4-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5cd5a41593a66ab3a8d0d901c14545ae01d6dd5d5e88b7d7c700638088f9276c
MD5 91596c3d126cfeb9dc06038c9b338c64
BLAKE2b-256 d6341a99bd173d835e2c306f12237ad4a161e7e5f3a45a8932d35220db2e7544

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