rss-to-json

repository·master·Indexed 41 days ago

https://github.com/nasa8x/rss-to-json

A Node.js utility for parsing ATOM and RSS feed resources and normalizing them into a consistent JSON object format. Version 2.1.1 provides a parse function that supports async/await and Promise-based syntax to convert feed URLs into JSON containing top-level metadata and an items array.

Tokens
931
Snippets
5
Records
7
Agent score
2%

What's inside rss-to-json

  1. Parse ATOM and RSS feeds using parse()

    master

    The parse function converts ATOM and RSS feed resources into a normalized JSON object. It supports both async/await and Promise-based syntax.

    To use it, import parse from rss-to-json and pass the URL of the feed as a string.

    const { parse } = require('rss-to-json');
    
    // Using async/await
    (async () => {
        var rss = await parse('https://blog.ethereum.org/feed.xml');
        console.log(JSON.stringify(rss, null, 3));
    })();
  2. Parse RSS feeds using Promises

    master

    If you prefer not to use async/await, you can use the .then() method on the Promise returned by parse().

    const { parse } = require('rss-to-json');
    
    parse('https://blog.ethereum.org/feed.xml').then(rss => {
        console.log(JSON.stringify(rss, null, 3));
    });
  3. JSON schema for RSS items

    master

    Each object within the items array in the conversion result contains the following fields:

    • title: The title of the feed item.
    • description: The content or summary of the item.
    • link: The URL to the item.
    • published: The publication date as a Unix timestamp (milliseconds).
    • created: The creation date as a Unix timestamp (milliseconds).
    • category: An array of categories associated with the item.
    • enclosures: An array of enclosure data.
    • media: An object containing media information.
  4. JSON output format of rss-to-json

    master

    When converting an RSS feed using rss-to-json, the resulting JSON object follows a specific structure. It contains top-level metadata about the feed and an items array containing the individual feed entries.

    {
       "title": "Feed Title",
       "description": "Feed Description",
       "link": "https://example.com",
       "image": "https://example.com/image.png",
       "category": [],
       "items": [
          {
             "title": "Item Title",
             "description": "Item Description",
             "link": "https://example.com/item",
             "published": 1626332400000,
             "created": 1626332400000,
             "category": [],
             "enclosures": [],
             "media": {}
          }
       ]
    }
  5. Convert RSS/Atom feeds using parse()

    master

    The parse function is the primary entrypoint for converting RSS or Atom feeds into normalized JSON objects. You can import it as a default export or as a named export parse from the package.

    import parse from 'rss-to-json';
    
    // Usage example (conceptual based on API surface)
    const result = await parse(rssUrl);
  6. Import the Parse class or function

    master
    The package exports both a default parse function and a named Parse entity (which may be the same function or a class depending on the implementation in ./parse). Use export { parse, Parse } to access these specifically.