This is a Python application that fetches and displays the latest news headlines from the NewsData.io API.
It supports both a rich terminal user interface (using Rich) and a Flask-based web UI with clickable links.
Inspired by wttr.in

- Fetches global or country-specific news headlines.
- Supports filtering by category, language, and country.
- Displays news in a well-formatted table on the terminal.
- Provides a simple web interface for browsing news.
- Uses the official NewsData.io Python client for API access.
- Configuration via environment variables (
.envsupport). - Easy command-line usage with flexible options.
- Python 3.7+
- pip
- NewsData.io API key (free tier available)
- Clone this repository
git clone https://github.com/renzorlive/newsapp.git
- Create and activate a Python virtual environment (recommended)
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
-
Create a
.envfile with your NewsData.io API keyecho "NEWSDATA_API_KEY=your_actual_api_key_here" > .env
Fetch news headlines and display them in your terminal with rich formatting.
python newsapp.py --category technology --language en --country us --limit 10
Options:
--category: News category (e.g., business, entertainment, general, health, science, sports, technology)--language: Language code (default: en)--country: Country code (2-letter ISO code, e.g., us, gb, ro)--limit: Number of headlines to fetch (default: 10, max: 100)--q: Keyword
Run the Flask-based web server with a simple UI.
python newsapp.py --web
Open your browser and go to:
http://localhost:8000/?category=technology\&language=en\&country=us\&limit=10
You can customize the URL parameters as needed.
.
├── newsapp.py — main application script containing terminal and web UI.
├── templates/
│ └── index.html - Template for web page
├── .env - environment file storing your API key (not included in repo).
└── requirements.txt - Python dependencies file.
newsdataapi: Official Python client for NewsData.io.rich: For rich terminal UI.Flask: Lightweight web framework.python-dotenv: Load environment variables from.env.
Install all packages via:
pip install -r requirements.txt
Refactored code structure for better readability and maintainability.
Added caching using cachelib.SimpleCache to reduce unnecessary API calls.
Improved date formatting for news articles to a user-friendly format.
Added validation for news categories and country codes.
Implemented error handling for API communication issues.
Enhanced terminal output using rich for better visualization.
Developed a Flask web interface with dynamic search, category, and country filters.
Included support for limiting the number of returned headlines.
Added Dark Mode on Web UI with toggle.
MIT License
- Powered by NewsData.io
- Terminal UI built on Rich
- Web UI powered by Flask
- Inspired by wttr.in
For issues and feature requests, please open an issue on this repository.
Feel free to star ⭐️ if you find this project useful!
If you enjoy using this app, please consider buying me a coffee!

