https://github.com/systemslibrarian/news-summarizer-api
Lightweight FastAPI app that pulls headlines on AI from GNews and generates summaries using OpenAI.
https://github.com/systemslibrarian/news-summarizer-api
Last synced: 1 day ago
JSON representation
Lightweight FastAPI app that pulls headlines on AI from GNews and generates summaries using OpenAI.
- Host: GitHub
- URL: https://github.com/systemslibrarian/news-summarizer-api
- Owner: systemslibrarian
- License: mit
- Created: 2025-07-19T01:21:53.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-27T00:37:50.000Z (10 months ago)
- Last Synced: 2025-07-27T03:39:14.233Z (10 months ago)
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π° News Summarizer API
A lightweight, FastAPI-based microservice that fetches the latest headlines on **AI news** from the GNews API and summarizes them using OpenAIβs language models.
---
## π Features
- π Fetches top news headlines related to a specific topic (`AI news` by default)
- π§ Generates concise summaries using the OpenAI API
- π‘ Exposes a simple REST API endpoint for summary retrieval
---
## π§± Prerequisites
Before running this project, youβll need:
- β
A **GNews API Key** β [https://gnews.io](https://gnews.io)
- β
An **OpenAI API Key** β [https://platform.openai.com](https://platform.openai.com)
- β
Python 3.7+
- β
`pip` for managing dependencies
---
## βοΈ Setup & Installation
Clone the repository:
```bash
git clone https://github.com/your-username/news-summarizer-api.git
cd news-summarizer-api
```
Install the required packages:
```bash
pip install -r requirements.txt
```
Create a `.env` file (or export environment variables directly):
```env
NEWS_API_KEY=your_gnews_api_key
OPENAI_API_KEY=your_openai_api_key
```
Replace `your_gnews_api_key` and `your_openai_api_key` with your actual keys.
---
## βΆοΈ Running Locally
Launch the FastAPI app using Uvicorn:
```bash
uvicorn main:app --reload
```
Visit: [http://localhost:8000/docs](http://localhost:8000/docs) to explore the Swagger UI.
---
## π Deployment (e.g., Render.com)
1. Push your code to GitHub
2. Create a new **Web Service** on [Render.com](https://render.com)
3. Set your environment variables in the Render dashboard:
- `NEWS_API_KEY`
- `OPENAI_API_KEY`
Render will automatically detect and deploy your FastAPI service.
---
## π‘ Example Usage
Once deployed, retrieve the summarized AI news by sending a request to:
```bash
curl https://your-service.onrender.com/summarize
```
---
## π License
This project is licensed under the [MIT License](./LICENSE).