GitHub Repository
View source code and contribute
Features
- Compatible with Python 2.6+ and Python 3
- No external dependencies
- Supports large messages
- Configurable retry logic with exponential backoff
Installation
Install the library using setup.py:Quick Start
Test the client using the built-in demo:- Python 3 / 2.7+
- With Retry Config
- Python 2.6
Basic Usage
Thebztcp.client.Client class handles the connection and streaming:
Configuration Options
Retry Configuration
Configure retry behavior with exponential backoff:| Parameter | Description | Default |
|---|---|---|
username | Your Benzinga TCP username | Required |
key | Your API access key | Required |
retries | Maximum number of retry attempts | - |
delay | Initial delay between retries (seconds) | - |
backoff | Multiplier for exponential backoff | - |
Advanced Usage
Low-Level Message Handling
For granular control over connection status and individual messages:Message Status Constants
| Status | Description |
|---|---|
STATUS_STREAM | Normal streaming content message |
Key Methods
| Method | Description |
|---|---|
content_items() | Generator that yields content dictionaries |
next_msg() | Returns the next raw message object |
disconnect() | Gracefully disconnects from the server |
Error Handling
The library raisesBzException for Benzinga-specific errors:
Complete Example
See Also
- Connection Guide - Server details and authentication
- Message Format - JSON structure reference
- Go Client - Alternative Go implementation