Liveblocks Python API Docs | dltHub
Build a Liveblocks-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
Liveblocks is a realtime collaboration backend and platform that provides REST APIs to manage rooms, storage, presence, Yjs docs, threads, groups, webhooks and project management features. The REST API base URL is https://api.liveblocks.io/v2 and All requests require a Bearer secret key in the Authorization header..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Liveblocks data in under 10 minutes.
What data can I load from Liveblocks?
Here are some of the endpoints you can load from Liveblocks:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| rooms | rooms | GET | data | List rooms; supports pagination (nextCursor) and filtering. |
| active_users | rooms/{roomId}/active_users | GET | data | List users currently present in a room (response contains data array). |
| storage | rooms/{roomId}/storage | GET | Get room Storage document (returns object; use ?format=json for plain JSON). | |
| ydoc | rooms/{roomId}/ydoc | GET | Get room Yjs document as JSON object. | |
| yjs_versions | rooms/{roomId}/versions | GET | data | List Yjs document version history; response includes data array and nextCursor. |
| threads | rooms/{roomId}/threads | GET | data | List threads (comments) in a room. |
| groups | groups | GET | data | List project groups; paginated (nextCursor). |
| webhooks | management/projects/{projectId}/webhooks | GET | data | Management: list project webhooks (requires read:all scope); paginated. |
| project_secret_key | management/projects/{projectId}/secret-key | GET | data | Management: get/rolled secret key (returns object with data). |
How do I authenticate with the Liveblocks API?
Authenticate by adding an HTTP header: Authorization: Bearer <YOUR_SECRET_KEY>. Some management endpoints require a Management API Access Token with the 'read:all' scope.
1. Get your credentials
- Sign in to https://liveblocks.io/dashboard. 2) Open the API keys / Project settings / API keys page. 3) Create or copy a secret key (labeled secret / management access token if applicable). 4) Use that secret in the Authorization header as a Bearer token.
2. Add them to .dlt/secrets.toml
[sources.liveblocks_react_source] secret_key = "your_liveblocks_secret_here"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Liveblocks API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python liveblocks_react_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline liveblocks_react_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset liveblocks_react_data The duckdb destination used duckdb:/liveblocks_react.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline liveblocks_react_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads rooms and active_users from the Liveblocks API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def liveblocks_react_source(secret_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.liveblocks.io/v2", "auth": { "type": "bearer", "token": secret_key, }, }, "resources": [ {"name": "rooms", "endpoint": {"path": "rooms", "data_selector": "data"}}, {"name": "active_users", "endpoint": {"path": "rooms/{roomId}/active_users", "data_selector": "data"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="liveblocks_react_pipeline", destination="duckdb", dataset_name="liveblocks_react_data", ) load_info = pipeline.run(liveblocks_react_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("liveblocks_react_pipeline").dataset() sessions_df = data.rooms.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM liveblocks_react_data.rooms LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("liveblocks_react_pipeline").dataset() data.rooms.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Liveblocks data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
If you see 401 or 403 responses, check the Authorization header. Common error bodies include: {"error":"MISSING_SECRET_KEY", "message":"Missing secret key in authentication header"} and {"error":"INVALID_SECRET_KEY"}. Management endpoints may return MISSING_MANAGEMENT_API_ACCESS_TOKEN or INVALID_MANAGEMENT_API_ACCESS_TOKEN and require a Management API Access Token with appropriate scope.
Rate limits and polling guidance
Some endpoints (e.g. active_users) recommend calling no more than once every ~10 seconds to avoid unnecessary load. Paginated endpoints return nextCursor—use startingAfter/cursor to page through results.
Pagination and selectors
Paginated list endpoints return an object with a top-level data array and nextCursor for the next page. Use the JSON key "data" as the records selector for list endpoints (e.g. rooms, groups, threads, yjs_versions, active_users).
Storage and Yjs quirks
The Storage GET returns a tree representation; use ?format=json to get plain JSON. Yjs document endpoints return objects (not top-level arrays) or binary updates for specific versions.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for Liveblocks?
Request dlt skills, commands, AGENT.md files, and AI-native context.