Tinybird is a powerful real-time analytics platform built on ClickHouse. It allows you to ingest, transform, and query large volumes of data with low latency.

Often, you want to stream changes from your Postgres database to Tinybird for real-time analytics. For instance, you might want to analyze order data as it’s created or updated in your database:

In this guide, you’ll learn how to use a Sequin webhook sink to stream Postgres changes to Tinybird in real-time.

Prerequisites

You are about to create a simple Tinybird data source that receives database changes. You’ll set up a webhook sink in Sequin that sends HTTP POST requests to Tinybird’s Events API with the payload of database changes.

You’ll need the following:

Create a Tinybird Data Source

Start by creating a new Data Source in Tinybird that will receive database changes from Sequin.

1

Log in to Tinybird

Log in to your Tinybird dashboard and navigate to the “Data Sources” tab.

2

Create new Data Source

Click on “Create Data Source”.

3

Select source type

Choose “Events API” as the source type.

4

Copy credentials

Copy the endpoint URL and Authorization token. You’ll need these for the next steps.

You’ve successfully created a Tinybird Data Source that can receive data via HTTP POST requests.

Create a webhook sink

Create a webhook sink that captures changes to your database and sends them to your Tinybird Data Source:

1

Create a new sink

Navigate to the “Sinks” tab, click the “Create Sink” button, and select “Webhook Sink”.

2

Select source table

Select the table you want to capture changes from (i.e public.orders).

3

Choose message type

Specify whether you want to receive changes or rows from the table.

In this example, you should choose “Rows” since you want to replicate the state of the table to Tinybird.

4

Configure backfill

You can optionally indicate if you want your webhook endpoint to receive a backfill of all or a portion of the table’s existing data. Since you want to replicate the state of the table, select to backfill all data.

5

Configure message grouping

Under “Message grouping”, leave the default option selected to ensure events for the same row are sent to your webhook endpoint in order.

6

Configure delivery settings

Under “Delivery configuration”, choose a conservative value for “Request timeout” and set “Batch size” to 1 since we’re just sending data to Tinybird.

7

Configure HTTP endpoint

Under “HTTP Endpoint”, enter the Tinybird Events API URL you copied earlier. Then click to “Add Encrypted Header” with the key Authorization and the value Bearer YOUR_TINYBIRD_TOKEN.

8

Name and create sink

Give your sink a name (i.e. tinybird_sink) and click “Create Webhook Sink”.

Your webhook sink is now created and ready to send events to Tinybird.

Test end-to-end

1

Create a row in your database

For example, insert a row into your table:

insert into orders (customer_id, amount)
values (1, 99.99);
2

Trace the change in the Sequin dashboard

In the Sequin console, open the Messages tab on your webhook sink and confirm that a message was delivered.

3

Confirm the data in Tinybird

  1. Go to your Tinybird dashboard
  2. Navigate to your Data Source
  3. Run a query to verify the data was received:
SELECT * FROM your_datasource_name
LIMIT 10

You’ve successfully streamed database changes to Tinybird!

Next steps

Build on this foundation:

  • Create Pipes in Tinybird to transform your data
  • Set up API endpoints in Tinybird to query your data
  • Create real-time dashboards with your streaming data
  • Configure additional webhook sinks for other tables

Was this page helpful?