Pusher Python API Docs | dltHub

Build a Pusher-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

Pusher is a hosted real-time messaging platform (Channels) that provides HTTP/REST APIs to publish events to channels, query channel state and presence user lists. The REST API base URL is https://api.pusherapp.com (clustered endpoints use https://api-<cluster>.pusher.com, e.g. https://api-mt1.pusher.com) and All requests require HMAC‑SHA256 signature authentication using your app key and secret (query‑parameter based signature)..

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 Pusher data in under 10 minutes.


What data can I load from Pusher?

Here are some of the endpoints you can load from Pusher:

ResourceEndpointMethodData selectorDescription
apps_channels/apps/{app_id}/channelsGETchannelsList occupied channels; supports filter_by_prefix and info attributes (user_count, subscription_count)
channels_channel/apps/{app_id}/channels/{channel_name}GETFetch info for a single channel; response is a hash with keys like occupied, user_count, subscription_count, cache
channels_channel_users/apps/{app_id}/channels/{channel_name}/usersGETusersList users in a presence channel (returns {"users": [{"id": "1"}, ...]})
apps_batch_events/apps/{app_id}/batch_eventsPOSTTrigger multiple events (response empty JSON or batch attributes when info requested)
apps_events/apps/{app_id}/eventsPOSTTrigger an event (response empty JSON or channels info when info param provided)
apps_channels_stats/apps/{app_id}/channels?info=subscription_count,user_countGETchannelsChannels info with requested attributes
apps_channels_prefix/apps/{app_id}/channels?filter_by_prefix=prefixGETchannelsFiltered channels list by prefix (e.g., presence-)

How do I authenticate with the Pusher API?

Authentication is done by including auth_key, auth_timestamp, auth_version (1.0) and auth_signature query parameters on every request. For requests with a non‑empty body, include body_md5 in the string‑to‑sign. The auth_signature is an HMAC SHA256 hex digest of the method, request path and sorted query string, signed with your app secret.

1. Get your credentials

  1. Sign in to the Pusher dashboard (https://dashboard.pusher.com). 2) Select or create an app. 3) In the App Keys or Credentials section copy the app_id, key (auth_key) and secret (app secret). 4) Note the app cluster (e.g., mt1) to select the correct API hostname. 5) Use the key and secret to compute auth_signature per docs.

2. Add them to .dlt/secrets.toml

[sources.pusher_source] app_id = "your_app_id" app_key = "your_app_key" app_secret = "your_app_secret" app_cluster = "your_app_cluster"

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 Pusher 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 pusher_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline pusher_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset pusher_data The duckdb destination used duckdb:/pusher.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

dlt pipeline pusher_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 apps_channels and channels_channel_users from the Pusher 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 pusher_source(app_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.pusherapp.com (clustered endpoints use https://api-<cluster>.pusher.com, e.g. https://api-mt1.pusher.com)", "auth": { "type": "http_basic_signed", "app_secret": app_key, }, }, "resources": [ {"name": "apps_channels", "endpoint": {"path": "apps/{app_id}/channels", "data_selector": "channels"}}, {"name": "channels_channel_users", "endpoint": {"path": "apps/{app_id}/channels/{channel_name}/users", "data_selector": "users"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="pusher_pipeline", destination="duckdb", dataset_name="pusher_data", ) load_info = pipeline.run(pusher_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("pusher_pipeline").dataset() sessions_df = data.apps_channels.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM pusher_data.apps_channels LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("pusher_pipeline").dataset() data.apps_channels.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 Pusher data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample 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 receive 401 or authentication errors ensure auth_key, auth_timestamp (within 600s of server time), auth_version=1.0 and auth_signature are present and the signature was computed using HMAC‑SHA256 with your app secret. For POST requests include body_md5 in the signed string. Check cluster (api host) and correct app_id in the path.

Rate limits and errors

The API uses standard HTTP status codes. 200 = success, 400 = bad request (e.g., requesting user_count for non‑presence channels), 401 = authentication error, 403 = forbidden (app disabled or over quota), 413 = payload too large (event data >10KB). Error details are returned in the JSON response body.

Pagination and filtering

Channels listing is returned as a hash keyed by channel name (not a paginated array). Use filter_by_prefix to limit results. When requesting info attributes (like user_count) ensure the attribute is applicable to the channel type; otherwise a 400 is returned.

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 Pusher?

Request dlt skills, commands, AGENT.md files, and AI-native context.