A robust and scalable news aggregation API built with Go, leveraging multiple news sources to provide trending topics, top headlines, and more.
- chore: Add support for building the application for ARM64 architecture. PR #20 by @tadeasf.
- 📝 Add CHANGELOG.md to document project changes. PR #18 by @tadeasf.
- 🔧 (automerge.yml): update automerge workflow to trigger on more events and improve merge commit message. PR #16 by @tadeasf.
- 🔧 (workflows): add GitHub Actions workflows for build, release, and changelog generation. PR #17 by @tadeasf.
- Fix-todo-to-issue-again. PR #9 by @tadeasf.
- 🔧 (todo-to-issue.yml): remove language-specific configuration for Go. PR #8 by @tadeasf.
- 🔧 (todo-to-issue.yml): fix escape sequences in language block comment patterns. PR #7 by @tadeasf.
- 🔧 (latest-changes.yml): ensure "Latest Changes" section exists in README. PR #6 by @tadeasf.
- Add endpoints for fetching news by keyword
- Add endpoints for fetching news by search query
- Add endpoints for fetching news by trending categories
- Implement scheduling via background cronjob for continuous article pulling
- Implement sentiment analysis, topics, and keywords extraction
- Fetch top headlines from multiple news sources (NewsAPI and GNews)
- Get news articles for trending topics
- Fetch trending categories from Exploding Topics
- Database integration with PostgreSQL for caching and data persistence
- API request limiting to comply with external API usage restrictions
- Swagger documentation for easy API exploration
GET /api/v1/health
: Health check endpointGET /api/v1/test-postgresql
: Test PostgreSQL connectionPOST /api/v1/init-db
: Initialize database tablesGET /api/v1/migrate
: Run database migrationsGET /api/v1/top-headlines
: Get top headlines from NewsAPI or GNewsGET /api/v1/trending-topics
: Get news articles for trending topicsGET /api/v1/fetch-trending-categories
: Fetch top 10 trending categories
For detailed API documentation, visit the Swagger UI at /docs/index.html
when running the server.
-
Clone the repository
-
Install dependencies:
go mod download
-
Create a
.env
file in the root directory with the following variables:PG_HOST=your_postgres_host PG_USER=your_postgres_user PG_PASSWORD=your_postgres_password PG_DB=your_postgres_database PG_PORT=your_postgres_port NEWS_API_KEY=your_newsapi_key GNEWS_API_KEY=your_gnews_key GIN_MODE=debug
-
Run the server:
go run main.go
Currently, there are no automated tests implemented. This is an area for future improvement.
To build the project, run the following command in the root directory:
go build -o go-news-api
This will create an executable named go-news-api
in the current directory.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository
- Create a new branch for your feature or fix
- Make changes and commit them with a descriptive commit message
- Push your changes to your forked repository
- Open a pull request to the main repository