Metadata-Version: 2.4
Name: finance-news-api
Version: 1.0.1
Summary: A powerful API that aggregates financial news and provides comprehensive market sentiment analysis
Home-page: https://github.com/pratyushkhanal/finance-news-api
Author: Pratyush Khanal
Author-email: pratyushkhanal@gmail.com
License: Apache-2.0
Project-URL: Bug Tracker, https://github.com/pratyushkhanal/finance-news-api/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.68.0
Requires-Dist: uvicorn>=0.15.0
Requires-Dist: python-dotenv>=0.19.0
Requires-Dist: peewee>=3.14.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.26.0
Requires-Dist: beautifulsoup4>=4.9.3
Requires-Dist: feedparser>=6.0.8
Requires-Dist: pandas>=1.3.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: textblob>=0.15.3
Requires-Dist: python-jose[cryptography]>=3.3.0
Requires-Dist: passlib[bcrypt]>=1.7.4
Requires-Dist: python-multipart>=0.0.5
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: playwright>=1.0.0
Requires-Dist: curl-cffi>=0.5.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: httpx; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-mock; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: aioresponses; extra == "dev"
Requires-Dist: responses; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Finance News API

A powerful API that aggregates financial news and provides comprehensive market sentiment analysis.

## Features

- 🔍 **Comprehensive Data Sources**
  - Yahoo Finance - Real-time market data and news
  - Reuters - Global financial news and analysis
  - Bloomberg - Market insights and breaking news
  - MarketWatch - Financial news and market commentary
  - Seeking Alpha - In-depth analysis and research
  - Company information and fundamentals
  - Market metrics and analyst recommendations

- 📊 **Advanced Analytics**
  - Sentiment analysis with granular classification
  - Subjectivity analysis
  - Time-based sentiment trends
  - Market sentiment aggregation
  - Multi-source news comparison and analysis
  - Source-specific sentiment tracking

- 📈 **Market Data**
  - Real-time and historical price data
  - Volume analysis
  - Key market metrics (P/E ratio, market cap, etc.)
  - Analyst recommendations
  - Company fundamentals

- ⚡ **Performance Features**
  - Async processing
  - Input validation
  - Comprehensive error handling
  - Flexible filtering options
  - Customizable news sources

## Getting Started

### Prerequisites

- Python 3.8+
- pip (Python package manager)

### Installation

1. Clone the repository:
```bash
git clone https://github.com/yourusername/finance-news-api.git
cd finance-news-api
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Set up environment variables:
```bash
# Create a .env file
touch .env

# Add the following to your .env file
ADMIN_USERNAME=your_admin_username
ADMIN_PASSWORD=your_secure_password
```

4. Run the application:
```bash
uvicorn main:app --reload
```

The API will be available at `http://localhost:8000`

## API Key Management

The API includes a built-in admin interface for managing API keys. Access it at `http://localhost:8000/admin`

### Security
- Admin interface is protected with HTTP Basic Authentication
- Admin credentials are configured via environment variables
- All admin actions require authentication
- API keys are securely generated and stored

### Features
- Create new users and generate API keys
- View all existing users and their API keys
- Delete users and their API keys
- Copy API keys to clipboard

### Using the Admin Interface
1. Open `http://localhost:8000/admin` in your browser
2. Enter your admin credentials when prompted
3. Use the form to create new users
4. View and manage existing users in the table
5. Copy API keys using the "Copy" button
6. Delete users using the "Delete" button

## API Usage

### Authentication
All endpoints require API key authentication. Include your API key in the `X-API-Key` header:

```python
import requests

headers = {
    "X-API-Key": "your_api_key_here"
}

response = requests.get("http://localhost:8000/api/news/AAPL", headers=headers)
```

### Example Endpoints

#### Get News for a Stock
```python
response = requests.get(
    "http://localhost:8000/api/news/AAPL",
    params={
        "sentiment_threshold": 0.2,
        "time_range_hours": 24,
        "sources": ["reuters", "bloomberg"]
    },
    headers=headers
)
```

## Documentation

- API Documentation: `/docs` (Swagger UI)
- ReDoc Documentation: `/redoc`
- Full API Documentation: [API.md](API.md)

## Development

### Running Tests
```bash
pytest
```

### Code Style
The project follows PEP 8 style guidelines. To check your code:
```bash
flake8 .
```

### Contributing
1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## Project Structure

```
finance-news-api/
├── main.py              # FastAPI application entry point
├── routers/            # API route handlers
│   ├── news.py         # News endpoints
│   ├── users.py        # User registration
│   └── admin.py        # Admin interface
├── services/           # Business logic
│   ├── yahoo.py        # Yahoo Finance integration
│   ├── news_sources.py # News source integrations
│   ├── sentiment.py    # Sentiment analysis
│   └── google.py       # Google News integration
├── templates/          # HTML templates
│   └── admin.html      # Admin interface template
├── middleware/         # Middleware components
│   └── admin_auth.py   # Admin authentication
├── database.py         # Database configuration
├── models.py           # SQLAlchemy models
├── schemas.py          # Pydantic models
├── auth.py            # API key authentication
├── tests/              # Test files
├── .env               # Environment variables
├── requirements.txt   # Project dependencies
├── API.md            # API documentation
└── README.md         # Project documentation
```

## Dependencies

- FastAPI - Web framework
- Uvicorn - ASGI server
- YFinance - Yahoo Finance API
- TextBlob - Sentiment analysis
- BeautifulSoup4 - Web scraping
- Feedparser - RSS feed parsing
- Playwright - Browser automation
- Python-dotenv - Environment management

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## Support

For support or to request a new API key, please contact:
- Email: pratyushkhanal95@gmail.com
- GitHub: https://github.com/pratyushkhanal

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. 
