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"])
Metadata
Release files for stockalert 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stockalert-2.1.0.tar.gz | 29.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stockalert-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.7 kB
Release files / stockalert-2.1.0.tar.gz
| Download URL | stockalert-2.1.0.tar.gz |
|---|---|
| Size | 29.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c878709ba7075e2c7cdfbbbd139131717d5a13bd139dbebe72a38866d4ecaa1d
|
|
BLAKE2b-256 checksum How to use checksums |
83a1f1b401b15f6f6cf0d131f478b7c44d229c259bad2ccb2447b6bb95d661df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / stockalert-2.1.0-py3-none-any.whl
| Download URL | stockalert-2.1.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8bf28c753fbae6ce0a9abed7877d2e9473a2b475b770b3cb2c064bcf3660544
|
|
BLAKE2b-256 checksum How to use checksums |
306a985515d9ed4b044b3866d88af968297bb84c797dbfb6bd76fdfdb19d627f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|