The News Aggregator API is a Node.js application that allows users to register, login, manage their news preferences, and fetch news articles based on their preferences. Users can also mark articles as read or favorite and search for news articles.
- Clone the repository:
git clone https://github.com/airtribe-projects/task-manager-api-v4vikasck.git
- Navigate to the project directory:
cd News_Aggregator_API
- Install the dependencies:
npm install
- Start the server:
npm start
-
Register
- URL:
/api/register
- Method:
POST
- Body:
{ "username": "testuser", "password": "testpassword" }
- Description: Registers a new user.
- URL:
-
Login
- URL:
/api/login
- Method:
POST
- Body:
{ "username": "testuser", "password": "testpassword" }
- Description: Logs in a user and returns a JWT token.
- URL:
-
Get Preferences
- URL:
/api/preferences
- Method:
GET
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Retrieves the user's news preferences.
- URL:
-
Update Preferences
- URL:
/api/preferences
- Method:
PUT
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <your_jwt_token>" }
- Body:
{ "categories": ["technology", "sports"], "languages": ["en", "es"] }
- Description: Updates the user's news preferences.
- URL:
-
Get News
- URL:
/api/news
- Method:
GET
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Fetches news articles based on the user's preferences.
- URL:
-
Mark Article as Read
- URL:
/api/news/:id/read
- Method:
POST
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Marks a news article as read.
- URL:
-
Mark Article as Favorite
- URL:
/api/news/:id/favorite
- Method:
POST
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Marks a news article as favorite.
- URL:
-
Get Read Articles
- URL:
/api/news/read
- Method:
GET
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Retrieves the list of read articles.
- URL:
-
Get Favorite Articles
- URL:
/api/news/favorites
- Method:
GET
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Retrieves the list of favorite articles.
- URL:
-
Search News
- URL:
/api/news/search/:keyword
- Method:
GET
- Headers:
{ "Authorization": "Bearer <your_jwt_token>" }
- Description: Searches for news articles based on a keyword.
- URL: