A lightweight FastAPI microservice that wraps yfinance, exposing RESTful endpoints for market data, perfect for non-Python projects, microservice architectures, and monitorable deployments.
- Language-agnostic: Get Yahoo Finance data via HTTP, no python dependency.
- Production-ready: Includes Prometheus metrics and health checks.
- Simple setup: Run with Docker, Poetry, or Docker Compose (Grafana/Prometheus included).
- Extendable: Built on FastAPI; easy to add routes or middleware.
| Feature | Description |
|---|---|
| Quote API | Fetch latest market quotes (OHLCV) for ticker symbols. |
| Historical API | Retrieve historical data within a date range. |
| Info API | Get company fundamentals (sector, market cap, etc.). |
| Health Check | Simple /health endpoint to verify service status. |
| Prometheus Metrics | /metrics endpoint for request count, errors, latency. |
| Endpoint | Description | Example |
|---|---|---|
GET /quote/{symbol} |
Latest quote for a symbol | /quote/AAPL |
GET /historical/{symbol}?start=YYYY-MM-DD&end=YYYY-MM-DD |
Historical OHLCV data | /historical/AAPL?start=2024-01-01&end=2024-02-01 |
GET /info/{symbol} |
Company details | /info/TSLA |
GET /health |
Health check | /health |
GET /metrics |
Prometheus metrics | /metrics |
docker pull ghcr.io/vorckea/yfinance-service:latest
docker run -p 8000:8000 ghcr.io/vorckea/yfinance-service:latestThen visit: http://localhost:8000/docs: Interactive Swagger UI
poetry install
poetry run uvicorn app.main:app --reloaddocker compose up --buildAccess:
- API: http://localhost:8000
- Prometheus: http://localhost:9090
- Grafana → http://localhost:3000
Relevant files:
- Prometheus config: monitoring/infra/prometheus.yml
- Alert rules: monitoring/infra/alert.rules.yml
- Dashboards: monitoring/dashboards/
Get the latest quote for Apple:
curl http://localhost:8000/quote/AAPLGet company info for Tesla:
curl http://localhost:8000/info/TSLAPrometheus query for average latency (5-minute window):
rate(request_latency_seconds_sum[5m]) / rate(request_latency_seconds_count[5m])
Contributions are welcome!
- Open an issue for bugs or new features.
- Look for good first issue labels to get started.
- Please see CONTRIBUTING.md
MIT License. See LICENSE for details.
Aksel Heggland Schrader (@Vorckea)