Official Python SDK for StockAlert.pro API
Project description
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")
# 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.7+ 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"])
Project details
Release history Release notifications | RSS feed
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.2.tar.gz
(27.1 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.2.tar.gz.
File metadata
- Download URL: stockalert-2.0.2.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f4b51441d8c4926a2bda694decb0fb99ccf14b5871ff7b78cd69730ea92e286
|
|
| MD5 |
38bf8a942138e8813e6d6ae3534a1a96
|
|
| BLAKE2b-256 |
28f64ea8073e7dfc131a39531cc762205bbac02bbd8056982e02642720abefb9
|
File details
Details for the file stockalert-2.0.2-py3-none-any.whl.
File metadata
- Download URL: stockalert-2.0.2-py3-none-any.whl
- Upload date:
- Size: 21.0 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 |
a4d870a08a3e166c162df4570428170f86683650998f441095331b1d211bec9c
|
|
| MD5 |
fcc67d956cda3904265fdc6045f3d6db
|
|
| BLAKE2b-256 |
c74457e9ad3151dff5cd6ee269828ab86874ddb0ba60b2cc6a82ab0457e7f5fe
|