{"library":"rss-parser","title":"RSS Parser","description":"rss-parser is a lightweight JavaScript library designed to convert RSS (and Atom) XML feeds into easily consumable JavaScript objects. It supports both Node.js environments and modern web browsers (with bundlers or pre-built distributions). The current stable version is 3.13.0, indicating active maintenance and regular updates. Key differentiators include its flexibility with both callback and Promise-based APIs, robust TypeScript support allowing custom field definitions for type safety, and the ability to parse either directly from a URL or an XML string. It provides a standardized output format, mapping common feed elements and offering a `contentSnippet` for HTML-stripped content. A notable consideration for browser usage is the need for a CORS proxy due to browser security restrictions on cross-origin requests.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install rss-parser"],"cli":null},"imports":["import Parser from 'rss-parser';","import type { ParserOptions } from 'rss-parser';","import type { Item } from 'rss-parser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Parser from 'rss-parser';\n\ntype CustomFeed = { feedId?: string };\ntype CustomItem = { authorName?: string };\n\nconst parser: Parser<CustomFeed, CustomItem> = new Parser({\n  customFields: {\n    feed: ['feedId'],\n    item: ['authorName']\n  },\n  // Headers are crucial for some feeds, e.g., to mimic a browser request\n  headers: {\n    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'\n  }\n});\n\n(async () => {\n  try {\n    // Use a CORS proxy for browser environments if fetching cross-origin\n    const CORS_PROXY = process.env.CORS_PROXY ?? 'https://api.allorigins.win/get?url=';\n    const feedUrl = 'https://www.reddit.com/.rss';\n    const urlToFetch = feedUrl.startsWith('http') ? CORS_PROXY + encodeURIComponent(feedUrl) : feedUrl;\n\n    const feed = await parser.parseURL(urlToFetch);\n\n    console.log(`Feed Title: ${feed.title}`);\n    console.log(`Custom Feed ID: ${feed.feedId ?? 'N/A'}`);\n\n    feed.items.forEach(item => {\n      console.log(`- ${item.title ?? 'No Title'} by ${item.authorName ?? item.creator ?? 'Unknown'} (Link: ${item.link ?? 'N/A'})`);\n    });\n  } catch (error) {\n    console.error('Error parsing RSS feed:', error);\n  }\n})();","lang":"typescript","description":"This quickstart demonstrates parsing an RSS feed from a URL, including custom type definitions for additional feed and item fields, error handling, and considerations for CORS proxies in browser environments. It showcases `async/await` syntax for promise resolution.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}