Skip to content

A REST API that allows users to submit any URL for an RSS feed. It parses the URL to extract links for all articles within it and returns a list of article titles and descriptions in JSON format. Endpoint is protected using JWT authentication.

Notifications You must be signed in to change notification settings

esr-zh/RSS-Feed-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSS Feed Parser API

This is my approach to creating a REST API that allows users to submit any URL for an RSS feed. It parses the URL to extract links for all articles within it and returns a list of article titles and descriptions in JSON format. The endpoint is protected using JWT authentication.

Requirements

  1. Clone the repo:
git clone [repository-url]
  1. Install the required packages:
pip install -r requirements.txt
  1. Set up Firebase Admin SDK by placing your firebase-sdk.json file in the project directory using Firebase Console:
    • Go to the Firebase Console.
    • Create a new project.
    • Go to Project settings > Service accounts.
    • Click "Generate new private key" and save the file

Running the Application

Start the Flask application:

python app.py

The server will start on http://localhost:5000.

Testing the application (Postman)

You can test the application using a tool like Postman or a browser for GET requests. I used postman, screenshots are given below.

  1. Set Request URL and Method:
  2. Add Authorization:
    • Go to the "Authorization" tab. Select "Bearer Token" from the Type dropdown. Paste your JWT token into the "Token" field.
    • Token is generated by running firebase_token_gen.html
  3. Set Request Body:
    • Go to the "Body" tab. Select "raw" and choose "JSON" from the dropdown. Enter the request url. For example:
{
  "url": "http://www.theguardian.com/world/usa/rss"
}

Example Urls to test the API:

API Endpoints

/parse-rss [POST]

  • Description: Parses the RSS feed from the given URL.
  • Headers: Authorization: Bearer [JWT Token]
  • Body:
{
  "url": "[RSS Feed URL]"
}

/show-data [GET]

  • Description: Displays the contents of the parsed RSS feeds.

Database Schema

The SQLite database consists of two tables:

  1. RSSFeed: Stores the RSS feed URLs and the last parsed time.
  2. Article: Stores the articles' titles and descriptions, linked to their respective RSS feeds.

Screenshots

  • Using postman returned the following JSON:

  • Sample RSS feed result shown as a table in /show-data

About

A REST API that allows users to submit any URL for an RSS feed. It parses the URL to extract links for all articles within it and returns a list of article titles and descriptions in JSON format. Endpoint is protected using JWT authentication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published