StockAlert.pro Python SDK
Official Python SDK for the StockAlert.pro API.
Installation
pip install stockalert
Install the optional async dependencies when you want to use AsyncStockAlert:
pip install "stockalert[async]"
Quick Start
from stockalert import StockAlert
# Initialize the client
client = StockAlert(api_key="sk_your_api_key")
# List all alerts
alerts = client.alerts.list()
print(f"Found {len(alerts.data)} alerts")
# Inspect subscription, quotas and usage
subscription = client.user.get_subscription()
print(subscription.account_type, subscription.alerts["quota"]["remaining"])
# Create a new alert
alert = client.alerts.create(
symbol="AAPL",
condition="price_above",
threshold=200,
notification="email"
)
# Pause alert
client.alerts.pause(alert.id)
# Delete alert
client.alerts.delete(alert.id)
Features
- 🐍 Python 3.8+ support
- 🔄 Automatic retries with exponential backoff
- 🛡️ Type hints for better IDE support
- 📦 Minimal dependencies
- 🧪 Comprehensive test suite
- 📚 Detailed documentation
Async Support
The SDK also supports async operations:
import asyncio
from stockalert import AsyncStockAlert
async def main():
async with AsyncStockAlert(api_key="sk_your_api_key") as client:
alerts = await client.alerts.list()
print(f"Found {len(alerts.data)} alerts")
asyncio.run(main())
Documentation
Full documentation is available at https://stockalert.pro/api/docs
License
MIT
🎯 More Examples
Pagination
# Iterate through all alerts efficiently
for alert in client.alerts.iterate():
print(f"{alert.symbol}: {alert.condition}")
Error Handling
from stockalert import StockAlert, APIError, RateLimitError
try:
alert = client.alerts.create(
symbol="AAPL",
condition="price_above",
threshold=200
)
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except APIError as e:
print(f"API error: {e.message} (status: {e.status_code})")
Environment Variables
import os
from stockalert import StockAlert
# API key from environment variable
client = StockAlert(api_key=os.environ["STOCKALERT_API_KEY"])
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stockalert-2.0.4.tar.gz
(28.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stockalert-2.0.4.tar.gz.
File metadata
- Download URL: stockalert-2.0.4.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a41410206e0c7cc945b2e95fd149ae9d20fb7548c7584e2c00da0202f54ef14
|
|
| MD5 |
7746ab96cf3620c459497ff8ed9a123d
|
|
| BLAKE2b-256 |
d5f2eb85c5bc191e82ab09eb4b60901ec658cdade9e1bb86dc17fb455c2b6d3d
|
File details
Details for the file stockalert-2.0.4-py3-none-any.whl.
File metadata
- Download URL: stockalert-2.0.4-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38db3cb46d9df4bc564dc57763eb9d1d0767280b13296f9568ec7b1faf914ad9
|
|
| MD5 |
291db511e728238fe201134ed4dec18e
|
|
| BLAKE2b-256 |
9e81efa86d3ff9a46e30d700d3ce512f152cbaf6ef018ed5003def9b191c5c6a
|