Skip to main content

Python SDK for Bulletins

Project description

bulletins

Python SDK for the Bulletins API. Async client, SSE streaming, and a declarative bot framework.

Install

uv add bulletins-sdk

Quick start

Client

import asyncio
from bulletins import BulletinsClient

async def main():
    client = BulletinsClient("bk_...", base_url="https://bulletins.no")

    async with client:
        await client.resolve()  # auto-resolves party + integration from key
        threads = await client.list_threads()
        for t in threads:
            print(f"{t.name} ({t.status})")

        await client.send_message(threads[0].id, "Hello from Python")

asyncio.run(main())

SSE streaming

async with client.stream_party() as stream:
    async for event in stream:
        print(f"[{event['type']}] {event.get('senderName')}: {event['content']}")

Bot

Declarative bot with auto-registration of custom event types:

import asyncio
from bulletins import Bot, EventTypeSpec

bot = Bot(
    "Ping Bot",
    event_types=[
        EventTypeSpec("bot:pong", content_schema={"message": {"type": "string"}}),
    ],
)

@bot.on("message")
async def handle(event, client):
    body = (event.content or {}).get("body", "")
    if body.startswith("!ping"):
        await client.send_message(event.thread_id, "pong")

asyncio.run(bot.start(api_key="bk_...", base_url="https://bulletins.no"))

Create the integration and API key in the Bulletins settings UI. The bot auto-resolves its party and integration from the API key and registers event types on startup.

API

BulletinsClient

Method Description
resolve() Auto-resolve party + integration from API key
list_threads() List threads for the active party
get_thread(id) Thread detail with events and participants
create_thread(name, to_party_id, body) Create a thread with initial message
list_events(thread_id, before, limit) Paginated event history
create_event(thread_id, type, content) Create any event type
send_message(thread_id, body) Send a text message
stream_party() SSE stream for all party events
stream_thread(thread_id) SSE stream for a single thread
list_integrations() List integrations
get_integration_detail(id) Integration with all child resources
create_event_type(integration_id, ...) Register a custom event type
create_action(integration_id, ...) Create an action
create_webhook(integration_id, ...) Create a webhook
create_api_key(integration_id, ...) Create an API key
get_agent_token(thread_id) LiveKit token for joining calls

Bot

Method Description
on(event_type) Decorator to register an event handler
start(api_key, base_url) Resolve identity, register event types, dispatch loop
stop() Stop the dispatch loop

Requirements

Python 3.12+, httpx.

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

bulletins_sdk-0.2.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

bulletins_sdk-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file bulletins_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: bulletins_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bulletins_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 77daba4da3cdb32fa20a1459f7011086ced65ef8393fd25b0411b50aea97d832
MD5 0c0bc559e544f542977d92597784c239
BLAKE2b-256 710db8621e06c21dcafd1f5a48eb5c80f18731917c90b1898f72f44c4342b92d

See more details on using hashes here.

File details

Details for the file bulletins_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bulletins_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"EndeavourOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bulletins_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8e3c457e2a331243afb50c4e695c6db8a1701926c7b243a8b2f3891c592502
MD5 873e5f4548c1dacc767d3f7a41b52ad9
BLAKE2b-256 26e3c0b7e6b376df047c2e77ac243dacc5ee9d149b25b808228229587137d9a5

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