News Aggregator with FastAPI
Boilerplate news aggregation application build for Reddit and NewsAPI. Main idea is to use lightweight development frameworks like FastAPI rather than heavy weight lifting with Django/ Flask. Further information can be found in Problem Statement document.
Request Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
The application is built in accordance with Problem Statement document. All of the features are implemented. All the contraints are implemented, along with project documentation and unit-tests.
What's Not Implemented
Current version of this project does not implement cache server or job queue to minimize performance dependence on external APIs.
Built With
Getting Started
General Technique to Aggregate
- Get list of registered APIs
- Loop over APIs
- Make JSON object of configurations for each API
- Write JSON parsers for each API
- Combine result in uniform format to display
- Return results
Detailed Approach
Every Request to API should be async; put the request in job tracker, get results and push back responses
News Listing Endpoint:
api.route('/news')
def get_top_news():
- Get all available APIs
- Call each API for getting top 10 news in JSON; Listing Function for Each API
- Aggregate news from all APIs, discard empty responses
News Search Endpoint
api.route('/news?query=bitcoin')
def get_search_results():
- Get all available APIs
- Call each API with search query to get top 10 results in JSON; Searching Function for Each API
- Aggregate results from all APIs, discard empty responses
Other Helper Functions
- News_API json parser for listing responses; should return only required fields; ["title", "link", "source"]
- Reddit_API json parser for listing results
Steps to Add any New API
- Make a new file for new-API in
src/external_api/
- Take
src/external_api/sample_api.py
as reference - Prepare API Mapping object
- Write JSON parser for that API
- Register your API in API_COLLECTION in
src/api_helper.py
Prerequisites
To run this project, should install project dependencies:
- Python3
- pip
- Intsall Python packages
Instructions to Run
- Clone the repo
git clone https://github.com/umairqadir97/news-aggregator-with-fastapi.git
- Open terminal in project folder
cd news-aggregator-with-fastapi
- Install python packages
pip3 install -r requirements.txt
-
Create your configurations file
src/config.py
. Takesrc/sample_config.py
as example -
Run server
python3 api.py
You can run tests with:
pytest
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b amazing_features
) - Commit your Changes (
git commit -m 'Add some Amazing Features'
) - Push to the Branch (
git push origin amazing_features
) - Open a Pull Request
Contribution guidelines
- Writing more unit tests
- Code review
- Feature Enhancement
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Muhammad Umair Qadir - Email
LinkedIn: LinkedIn