Official HypeRate Python Bindings
A Python client library for connecting to the HypeRate WebSocket API to receive real-time heartbeat and clip data.
Features
- Real-time heartbeat monitoring - Subscribe to live heart rate data from HypeRate devices
- Clip notifications - Receive notifications when clips are created
- Async/await support - Built with asyncio for efficient WebSocket handling
- Event-driven architecture - Register handlers for different event types
- Type hints - Full type annotation support for better IDE integration
- Comprehensive logging - Built-in logging with configurable levels
- Error handling - Robust error handling and connection management
Supported Python Versions
This library supports and is tested on:
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
- Python 3.13
- Python 3.14
Installation
pip install hyperate
Quick Start
import asyncio
import hyperate
async def main():
# Initialize and connect to HypeRate
client = hyperate.HypeRate("your_api_token_here")
await client.connect()
# Define and register event handlers
def on_heartbeat(data):
print(f"Heartbeat received: {data['hr']} BPM")
def on_connected():
print("Connected to HypeRate!")
def on_clip(data):
print(f"New clip: {data['twitch_slug']}")
client.on('heartbeat', on_heartbeat)
client.on('connected', on_connected) # Note: this fires after connection is already established
client.on('clip', on_clip)
# Subscribe to a device's heartbeat data
await client.join_heartbeat_channel("internal-testing") # Use "internal-testing" for testing
# Keep the connection alive
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
print("Exiting...")
finally:
await client.disconnect()
# Run the client
if __name__ == "__main__":
asyncio.run(main())
Alternative Quick Start (Lambda Style)
import asyncio
from hyperate import HypeRate
async def main():
client = HypeRate("your_api_token_here")
await client.connect()
# Register handlers with lambda functions
client.on('heartbeat', lambda data: print(f"❤️ {data['hr']} BPM"))
client.on('clip', lambda data: print(f"🎬 Clip: {data['twitch_slug']}"))
await client.join_heartbeat_channel("internal-testing")
try:
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
pass
finally:
await client.disconnect()
asyncio.run(main())
API Documentation
HypeRate Class
Constructor
HypeRate(api_token: str, base_url: str = "wss://app.hyperate.io/socket/websocket", logger: Optional[logging.Logger] = None)
Methods
connect()- Connect to the HypeRate WebSocketdisconnect()- Disconnect from the WebSocketjoin_heartbeat_channel(device_id)- Subscribe to heartbeat data for a deviceleave_heartbeat_channel(device_id)- Unsubscribe from heartbeat datajoin_clips_channel(device_id)- Subscribe to clip notifications for a deviceleave_clips_channel(device_id)- Unsubscribe from clip notificationson(event, handler)- Register an event handler
Events
connected- Fired when connected to HypeRatedisconnected- Fired when disconnected from HypeRateheartbeat- Fired when heartbeat data is receivedclip- Fired when clip data is receivedchannel_joined- Fired when a channel is successfully joinedchannel_left- Fired when a channel is successfully left
Usage Notes
- Connect to HypeRate first with
await client.connect()before registering handlers - Use
"internal-testing"as device ID for testing purposes - Event handlers registered after connection won't receive the initial
connectedevent - Use
while True:for the main loop as the client manages the connection state internally
Device Class
Utility class for device ID validation and extraction.
Methods
is_valid_device_id(device_id)- Check if a device ID is validextract_device_id(input_str)- Extract device ID from URL or string
Development
Setting up the development environment
- Clone the repository
- Install development dependencies:
pip install -r .\Tests\test_requirements.txt
- Install the package in development mode:
pip install -e .
Running Tests
Use the comprehensive test runner:
# Run all tests
python Tests/run_tests.py --all
# Run specific test types
python Tests/run_tests.py --unit # Unit tests only
python Tests/run_tests.py --integration # Mocked scenario tests
python Tests/run_tests.py --real-integration --token=your_token # Real API integration
python Tests/run_tests.py --performance # Performance tests
# Run with coverage
python Tests/run_tests.py --coverage
# Run code quality checks
python Tests/run_tests.py --lint
Real Integration Tests
To run tests against the actual HypeRate API, provide your API token via command line:
# Using pytest (recommended)
python -m pytest Tests/test_real_integration.py --token=your_actual_api_token_here
# Using direct script execution
python Tests/test_real_integration.py --token=your_actual_api_token_here
# Using the test runner with token
python Tests/run_tests.py --real-integration --token=your_actual_api_token_here
Code Quality
This project maintains high code quality standards:
- Code Quality Checks: PyLint (10.0/10.0), Mypy (strict mode), and Flake8 style checking
- Test Coverage: Minimum 85% code coverage required
- Comprehensive Testing: Unit, integration, and performance tests
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass and code quality checks pass
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
Metadata
Release files for hyperate 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hyperate-1.0.1.tar.gz | 12.8 kB | With provenance | Details for hyperate-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hyperate-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for hyperate-1.0.1-py3-none-any.whl |
Total release size: 23.4 kB
Release files / hyperate-1.0.1.tar.gz
| Download URL | hyperate-1.0.1.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96511256e870d3c09589187f12cadb82e8365be9420c82b80e9511bc5e3173fa
|
|
BLAKE2b-256 checksum How to use checksums |
f4cd6843331c1080e1d0ff24488393410b22701bba97240190bac2e8afb4572e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2025.
Transparency logRelease files / hyperate-1.0.1-py3-none-any.whl
| Download URL | hyperate-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2723f0e2eb3289d0b7126429240cb7de05d4cdcd122777285af3bd1ddbfed3e4
|
|
BLAKE2b-256 checksum How to use checksums |
6886f4fab8f841fa7bd4d57de3db007f4b3e22f05a2c9131d8b810d19ca643de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2025.
Transparency logSecurity for hyperate 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hyperate-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.