Skip to content

DuckDB Extension

Radio

Receive WebSocket or Redis Pub/Sub messages in DuckDB and query the buffered events as tables. Send messages and inspect delivery state from SQL.

52,108
extension loads · last 90 days
On this page

Collect live messages for SQL queries

Radio connects to WebSocket feeds or Redis Pub/Sub channels and buffers incoming messages inside the DuckDB process. SQL functions read those messages as rows and can queue outgoing messages.

Use it to inspect a live feed or combine recent events with local data. You need an accessible messaging endpoint. The buffers are temporary, so save messages to a table when you need to retain them beyond the running session.

Example

Read messages from a WebSocket feed

Replace the example URL with a feed you can access. Subscribe, wait briefly for messages, read the buffer, then unsubscribe.

Before you run it: Supply a working WebSocket URL. stream.example.com is a placeholder, not a demo service.

Run this example in the DuckDB CLI or a native client.

SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL radio FROM query_farm;
LOAD radio FROM query_farm;

SET VARIABLE qf_feed = 'wss://stream.example.com/events';
CALL radio_subscribe(getvariable('qf_feed'));
CALL radio_listen(true, INTERVAL '2 seconds');
SELECT receive_time, channel, message
FROM radio_subscription_received_messages(getvariable('qf_feed'))
ORDER BY receive_time DESC
LIMIT 10;
CALL radio_unsubscribe(getvariable('qf_feed'));

The query can return no rows if no messages arrive. Buffers live in the DuckDB process; they are not a durable message store.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Inbox
radio_received_messages() Object type: Table function Returns the messages held in every subscription's receive queue: subscription_id, subscription_url, message_id, message_type (message, error, connection, disconnection), receive_time, seen_count, channel and the message payload as BLOB (use decode(message) for UTF-8 text).
radio_subscription_received_message_add() Object type: Table function Adds a message to a subscription's receive queue as if it had arrived from the network and returns its message_id.
radio_subscription_received_messages() Object type: Table function Returns the messages in one subscription's receive queue: message_id, receive_time, seen_count, channel and message (BLOB).
Listening
radio_listen() Object type: Table function Returns the subscriptions (subscription_id, subscription_url) holding received messages that no query has read yet.
radio_subscribe() Object type: Table function Opens a subscription and returns its subscription_id.
radio_subscriptions() Object type: Table function Lists the active subscriptions: subscription_id, url, creation_time, activation_time (NULL until connected), disabled, received_last_message_time, received_messages_processed, transmit_messages_processed, transmit_last_queue_time, transmit_last_success_time, transmit_last_failure_time, transmit_successes and transmit_failures.
radio_unsubscribe() Object type: Table function Closes the subscription for a URL and returns its subscription_id.
Maintenance
radio_flush() Object type: Table function Waits up to timeout for every subscription's transmit queue to finish (send, or give up on) its pending messages.
radio_sleep() Object type: Table function Sleeps for duration and returns true.
radio_version() Object type: Scalar function Returns the version of the loaded Radio extension.
Outbox
radio_subscription_transmit_message_delete() Object type: Table function Removes one message, by message_id, from a subscription's transmit queue, cancelling it if it has not been sent yet.
radio_subscription_transmit_messages() Object type: Table function Returns one subscription's transmit queue: message_id, creation_time, last_attempt_start_time, last_attempt_end_time, state (pending, sending, sent, retries_exhausted, time_expired), expire_duration_ms, max_attempts, try_count, channel, message and result (the last transport error, if any).
radio_subscription_transmit_messages_delete_finished() Object type: Table function Removes the transmit messages of a subscription that are finished — sent, retries_exhausted or time_expired — and returns true.
radio_transmit_message() Object type: Table function Queues message for sending on the subscription for url and returns its message_id.

API Reference

Function Reference

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Experimental
Software License MIT
Pricing Free
Written In C++
Source Available Yes
View on GitHub
Usage
52,108
loads · last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows Not available
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 7.03 MB
Linux aarch64 6.62 MB
macOS Apple Silicon 5.21 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported
  • Haybarn v1.5.6 Built-in community repository Supported

Browser examples use Haybarn-Wasm 2.0.0-rc12.

Checked .

Learn and explore

Tutorials and articles

Writing about Radio: how it works, what changed, and why.