|
| 1 | +--- |
| 2 | +title: "Overview" |
| 3 | +description: "A high-level guide to Benzinga's real-time WebSocket data streams." |
| 4 | +--- |
| 5 | + |
| 6 | +Benzinga's WebSocket API delivers low-latency, push-based financial data directly to your application. Instead of repeatedly polling a REST endpoint, you open a single persistent connection and receive events the moment they're available — analyst ratings, earnings results, news, transcripts, and more. |
| 7 | + |
| 8 | +All streams share the same base endpoint, authentication model, and message envelope, so the patterns you learn on one stream apply everywhere. |
| 9 | + |
| 10 | +## How it works |
| 11 | + |
| 12 | +<Steps> |
| 13 | + <Step title="Authenticate"> |
| 14 | + Obtain a Benzinga API token from the [Benzinga Console](https://www.api.benzinga.com/token) and append it as a `token` query parameter when opening the connection. |
| 15 | + </Step> |
| 16 | + <Step title="Connect"> |
| 17 | + Open a WebSocket connection to the stream URL for the data you need — for example `wss://api.benzinga.com/api/v1/analyst/insights/stream?token=YOUR_TOKEN`. |
| 18 | + </Step> |
| 19 | + <Step title="Receive events"> |
| 20 | + Messages arrive as JSON objects with a consistent envelope: an `id`, `api_version`, `kind`, and a `data` block that carries the action (`created`, `updated`, or `deleted`) and the payload. |
| 21 | + </Step> |
| 22 | + <Step title="Keep the connection alive"> |
| 23 | + Send a `ping` plain-text frame periodically (every 30–60 s). The server responds with `pong`. The server also sends its own ping every 10 s — most WebSocket libraries handle this automatically. |
| 24 | + </Step> |
| 25 | +</Steps> |
| 26 | + |
| 27 | +## Available streams |
| 28 | + |
| 29 | +<CardGroup cols={2}> |
| 30 | + <Card title="Analyst Insights" icon="chart-line" href="/ws-reference/data-websocket/get-analyst-insights-stream"> |
| 31 | + Real-time analyst ratings, price targets, and detailed recommendations as they're published. |
| 32 | + </Card> |
| 33 | + <Card title="Ratings" icon="star" href="/ws-reference/data-websocket/get-calendar-ratings-stream"> |
| 34 | + Analyst rating changes and price target updates from major firms. |
| 35 | + </Card> |
| 36 | + <Card title="Consensus Ratings" icon="scale-balanced" href="/ws-reference/data-websocket/get-consensus-ratings-stream"> |
| 37 | + Aggregated consensus ratings and price targets across all tracked analysts. |
| 38 | + </Card> |
| 39 | + <Card title="Earnings" icon="sack-dollar" href="/ws-reference/data-websocket/get-calendar-earnings-stream"> |
| 40 | + Earnings announcements with EPS, revenue, estimates, and surprise metrics. |
| 41 | + </Card> |
| 42 | + <Card title="Bulls/Bears Say" icon="comments" href="/ws-reference/data-websocket/get-bulls-bears-say-stream"> |
| 43 | + Bull and bear case scenarios for securities, published in real time. |
| 44 | + </Card> |
| 45 | + <Card title="News" icon="newspaper" href="/ws-reference/data-websocket/get-news-stream"> |
| 46 | + Breaking news articles and market updates from Benzinga's editorial team. |
| 47 | + </Card> |
| 48 | + <Card title="Earnings Call Transcripts" icon="microphone" href="/ws-reference/data-websocket/get-transcripts-stream"> |
| 49 | + Live earnings call transcripts delivered sentence-by-sentence as they're spoken. |
| 50 | + </Card> |
| 51 | +</CardGroup> |
| 52 | + |
| 53 | +## Message envelope |
| 54 | + |
| 55 | +Every stream message follows the same top-level structure: |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "id": "550e8400-e29b-41d4-a716-446655440000", |
| 60 | + "api_version": "websocket/v1", |
| 61 | + "kind": "<stream-type>", |
| 62 | + "data": { |
| 63 | + "action": "created", |
| 64 | + "id": "<record-id>", |
| 65 | + "timestamp": "2024-10-08T10:00:00Z", |
| 66 | + "content": { ... } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +| Field | Description | |
| 72 | +|-------|-------------| |
| 73 | +| `id` | Unique message ID — use this to deduplicate on reconnect | |
| 74 | +| `api_version` | Protocol version of the message | |
| 75 | +| `kind` | Identifies which stream the message came from | |
| 76 | +| `data.action` | One of `created`, `updated`, or `deleted` | |
| 77 | +| `data.content` | Stream-specific payload | |
| 78 | + |
| 79 | +## Reference pages |
| 80 | + |
| 81 | +<CardGroup cols={3}> |
| 82 | + <Card title="Authentication" icon="key" href="/ws-reference/authentication"> |
| 83 | + How to obtain and use your API token. |
| 84 | + </Card> |
| 85 | + <Card title="Supported Actions" icon="bolt" href="/ws-reference/actions"> |
| 86 | + `ping` and `replay` commands you can send on any stream. |
| 87 | + </Card> |
| 88 | + <Card title="Errors" icon="triangle-exclamation" href="/ws-reference/errors"> |
| 89 | + Error codes and how to handle connection failures. |
| 90 | + </Card> |
| 91 | +</CardGroup> |
0 commit comments