# WebSocket & SSE Event Recorder | Stream Capture (`produkdigitalali/websocket-sse-event-recorder`) Actor

Capture bounded WebSocket frames and Server-Sent Events from public webpages with safe metadata-only defaults.

- **URL**: https://apify.com/produkdigitalali/websocket-sse-event-recorder.md
- **Developed by:** [ProdukDigitalAli](https://apify.com/produkdigitalali) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 stream event recordeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## WebSocket & SSE Event Recorder

Capture WebSocket frames and Server-Sent Events that a public webpage actually receives, then export bounded structured rows for debugging, monitoring, and integration work.

### Quick start

Provide one or more public webpage URLs. The safe default records protocol, direction, byte size, and timestamps without storing message contents.

### Use cases

- Diagnose live dashboards, chats, tickers, and notification feeds.
- Archive bounded event samples from a public page you are authorized to inspect.
- Confirm whether a webpage uses WebSocket, SSE, or both.
- Monitor event volume and stream availability over time.

### Output

Each captured event becomes one dataset row. Each page also produces a summary row. Stream URLs omit query strings and fragments. Payload text is disabled by default; when enabled, it is redacted and truncated.

### Limits and safety

Public HTTP(S) destinations on ports 80/443 only. Private, local, metadata, reserved, and special networks are blocked and every browser request is rechecked. The Actor does not replay, modify, inject, or probe messages. It does not bypass authentication, CAPTCHAs, access controls, or rate limits. Never use it on private or sensitive sessions.

### Pricing

USD 0.001 per stored stream event, plus the standard Actor-start event. A five-event capture costs about USD 0.005 plus startup before Store discounts. Failed pages and dropped events are not charged. Cloud tests measured about USD 0.00071 platform cost for six SSE events and USD 0.00128 for a capped 20-frame WebSocket run; pricing will be reviewed after real external usage.

### Related tools

Use Browser Network & HAR Capture Inspector for ordinary HTTP/XHR/Fetch diagnostics and HAR export. Use this Actor when the real-time WebSocket frame or SSE message is the result you need.

### Ready-to-use examples

- examples/01-safe-metadata-capture.json: smallest safe zero-event smoke test.
- examples/02-sse-live-clock.json: capture a public SSE live clock.
- examples/03-websocket-market-stream.json: record a bounded WebSocket sample with a hard event cap.

### Support

Include the run ID, public page URL, protocol, event cap, and sanitized expected behavior. Never post payload contents, credentials, cookies, authorization headers, or private stream URLs.

# Actor input Schema

## `startUrls` (type: `array`):

Public webpages that initiate WebSocket or SSE connections.

## `captureDurationSeconds` (type: `integer`):

Seconds to listen after navigation.

## `maxEventsPerPage` (type: `integer`):

Hard event cap per page.

## `payloadMode` (type: `string`):

Metadata stores sizes only. Text stores redacted and truncated payload text.

## `maxPayloadBytes` (type: `integer`):

Maximum UTF-8 bytes stored for each opted-in text payload.

## `includeSentFrames` (type: `boolean`):

Store WebSocket frames sent by the page.

## `includeReceivedFrames` (type: `boolean`):

Store WebSocket frames received by the page.

## `includeWebSocket` (type: `boolean`):

Capture WebSocket frame events.

## `includeSse` (type: `boolean`):

Capture Server-Sent Event messages.

## `waitUntil` (type: `string`):

Browser lifecycle point used before the listening period begins.

## `maxUserChargeUsd` (type: `number`):

Additional input-side PPE guard.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://example.com"
    }
  ],
  "captureDurationSeconds": 15,
  "maxEventsPerPage": 500,
  "payloadMode": "metadata",
  "maxPayloadBytes": 4096,
  "includeSentFrames": false,
  "includeReceivedFrames": true,
  "includeWebSocket": true,
  "includeSse": true,
  "waitUntil": "domcontentloaded",
  "maxUserChargeUsd": 1
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://example.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("produkdigitalali/websocket-sse-event-recorder").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": [{ "url": "https://example.com" }] }

# Run the Actor and wait for it to finish
run = client.actor("produkdigitalali/websocket-sse-event-recorder").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://example.com"
    }
  ]
}' |
apify call produkdigitalali/websocket-sse-event-recorder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,produkdigitalali/websocket-sse-event-recorder"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/pUTpogIwCUZTOSWF8/builds/li7ph7ChFFrPchti0/openapi.json
