Skip to main content

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")

# 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"])

Project details


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.3.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stockalert-2.0.3-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file stockalert-2.0.3.tar.gz.

File metadata

  • Download URL: stockalert-2.0.3.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for stockalert-2.0.3.tar.gz
Algorithm Hash digest
SHA256 419db2f908c20b211b1feee686f816b135394bff2ca98457ea3ba4787b1b394c
MD5 6a0472bc823cea5801b50044b699953e
BLAKE2b-256 b77521e29a29090d974026d0ecbbf89fa8e48a359bb83366aa37913373f7efae

See more details on using hashes here.

File details

Details for the file stockalert-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: stockalert-2.0.3-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

Hashes for stockalert-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c77968c982e963fefcfe44a88b969b6c27f5da888ef46d2bdd71dcd72aa22caa
MD5 ff55d01af7bffdc865e760918b104ccf
BLAKE2b-256 5919ece088e2174749d4fbccaaf71c1fa348e7e7f620f90c71308c00fce77ce1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page