
Research
Security News
Malicious npm Package Wipes Codebases with Remote Trigger
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
A powerful API that aggregates financial news and provides comprehensive market sentiment analysis
A powerful API that aggregates financial news and provides comprehensive market sentiment analysis.
š Comprehensive Data Sources
š Advanced Analytics
š Market Data
ā” Performance Features
The easiest way to install Finance News API is directly from PyPI:
pip install finance-news-api
git clone https://github.com/pratyushkhanal/finance-news-api.git
cd finance-news-api
pip install -r requirements.txt
After installing the package, you can use it in your Python code:
from newsapi2 import app
import uvicorn
# Run the FastAPI application
uvicorn.run(app, host="0.0.0.0", port=8000)
You can also import specific services and use them directly:
from newsapi2.services.news_sources import get_news
from newsapi2.services.sentiment import analyze_sentiment
# Get news for a specific stock
apple_news = get_news("AAPL")
# Analyze sentiment of a text
sentiment_score = analyze_sentiment("This company reported better than expected earnings")
If you want to use the Finance News API as a client:
import requests
headers = {
"X-API-Key": "your_api_key_here"
}
# Get news for Apple
response = requests.get(
"http://your-api-endpoint.com/api/news/AAPL",
headers=headers,
params={
"sentiment_threshold": 0.2,
"time_range_hours": 24,
"sources": ["reuters", "bloomberg"]
}
)
# Parse the JSON response
news_data = response.json()
# Print the results
for article in news_data["articles"]:
print(f"Title: {article['title']}")
print(f"Source: {article['source']}")
print(f"Sentiment: {article['sentiment_score']}")
print(f"URL: {article['url']}")
print("---")
To upgrade to the latest version:
pip install --upgrade finance-news-api
After installing the package, you can run it directly from the command line:
# Start the API server (if configured in entry_points)
finance-news-api
# Or run it using Python
python -m newsapi2.main
This will start the FastAPI application on the default host (0.0.0.0) and port (8000).
You can also run the Finance News API as a web service:
# Create a .env file
touch .env
# Add the following to your .env file
ADMIN_USERNAME=your_admin_username
ADMIN_PASSWORD=your_secure_password
# If installed from PyPI
finance-news-api serve
# Or if using the source code
uvicorn main:app --reload
The API will be available at http://localhost:8000
The API includes a built-in admin interface for managing API keys. Access it at http://localhost:8000/admin
http://localhost:8000/admin
in your browserAll 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)
response = requests.get(
"http://localhost:8000/api/news/AAPL",
params={
"sentiment_threshold": 0.2,
"time_range_hours": 24,
"sources": ["reuters", "bloomberg"]
},
headers=headers
)
/docs
(Swagger UI)/redoc
pytest
The project follows PEP 8 style guidelines. To check your code:
flake8 .
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
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For support or to request a new API key, please contact:
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A powerful API that aggregates financial news and provides comprehensive market sentiment analysis
We found that finance-news-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.
Security News
New CNA status enables OpenJS Foundation to assign CVEs for security vulnerabilities in projects like ESLint, Fastify, Electron, and others, while leaving disclosure responsibility with individual maintainers.