Skip to main content

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

Project description

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:
git clone https://github.com/yourusername/finance-news-api.git
cd finance-news-api
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
# Create a .env file
touch .env

# Add the following to your .env file
ADMIN_USERNAME=your_admin_username
ADMIN_PASSWORD=your_secure_password
  1. Run the application:
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:

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

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

Development

Running Tests

pytest

Code Style

The project follows PEP 8 style guidelines. To check your code:

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 file for details.

Support

For support or to request a new API key, please contact:

Contributing

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

finance_news_api-1.0.1-py3-none-any.whl (139.3 kB view details)

Uploaded Python 3

File details

Details for the file finance_news_api-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for finance_news_api-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b031f1b454db2a47e94f464e493a0a823849be33619db6d203beb18793d20dae
MD5 a4bfe98b083ca6680c4e8fc5a37f09e8
BLAKE2b-256 8b270ba7528e47f99f5cffeba458803b56864b0fddc7c03dba3fba6328f3ae1b

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