Spaces:
Sleeping
Sleeping
metadata
title: Ticker Monitor Api
emoji: π
colorFrom: purple
colorTo: pink
sdk: docker
pinned: false
license: mit
short_description: SP500 & NASDAQ ticker monitoring API
Stock Monitoring API π
A FastAPI-based REST API for monitoring S&P 500 and Nasdaq 100 stock tickers with real-time data updates.
Features
- Stock Data Management: Query and update tickers for S&P 500 and Nasdaq 100 indices
- Automatic Data Updates: Background tasks to fetch latest stock data from Yahoo Finance
- RESTful API: Clean, documented endpoints with OpenAPI/Swagger integration
- MySQL Integration: Persistent storage with async SQLAlchemy
- Authentication: Secure API key-based authentication
- Health Monitoring: Built-in health checks and version information
API Endpoints
Public Endpoints
GET /
- Health check and system informationGET /tickers
- List all available tickers with filtering optionsGET /data/tickers/{ticker}
- Get historical data for a specific ticker
Protected Endpoints (Require API Key)
POST /tickers/update
- Update ticker list from Wikipedia sourcesPOST /tickers/update-async
- Async ticker updates with task trackingPOST /data/download-all
- Download latest stock data (bulk operation)GET /tasks
- List background tasksGET /tasks/{task_id}
- Get specific task statusDELETE /tasks/old
- Clean up old completed tasks
Usage
Authentication
Protected endpoints require an API key in the Authorization header:
Authorization: Bearer your_api_key_here
Example Requests
# Get system health
curl https://your-space-name.hf.space/
# List S&P 500 tickers
curl "https://your-space-name.hf.space/tickers?is_sp500=true&limit=10"
# Get AAPL stock data (last 30 days)
curl "https://your-space-name.hf.space/data/tickers/AAPL?days=30"
# Update all stock data (requires API key)
curl -X POST "https://your-space-name.hf.space/data/download-all" \
-H "Authorization: Bearer your_api_key"
Configuration
Set these environment variables in your Hugging Face Space:
MYSQL_USER
- Database usernameMYSQL_PASSWORD
- Database passwordMYSQL_HOST
- Database hostMYSQL_PORT
- Database port (default: 3306)MYSQL_DB
- Database nameAPI_KEY
- Secure API key for protected endpoints
Technical Details
- Framework: FastAPI with async/await support
- Database: MySQL with SQLAlchemy async ORM
- Data Sources: Wikipedia (ticker lists), Yahoo Finance (stock data)
- Deployment: Docker container optimized for Hugging Face Spaces
- Python: 3.12 with production-ready dependencies
API Documentation
Once deployed, visit /docs
for interactive Swagger documentation or /redoc
for alternative API docs.
Built for Hugging Face Spaces with β€οΈ