Skip to content
Joshua Strobl edited this page May 25, 2020 · 1 revision

Feedie's API is intentionally kept as simple as possible.

New Parser

To create a new Feedie RSS parser, you just need to provide the following construction parameters to our new feedie.Parser class constructor:

Name Type Description
url string URL to the RSS XML feed
callback (Parser | Error) => void Callback to handle parser completions or Errors

Feedie will create a new Parser class that will attempt to fetch the RSS feed text using the Fetch API and Promises. Feedie does NOT support browsers which do NOT support either of the technologies noted above. Please use CanIUse to see if your required supported browser is listed.

Example:

new feedie.Parser("https://example.com", (selfOrErr) => {
    if (selfOrErr instanceof Error) { // Got an error when parsing
        console.log(`Error during RSS parsing: ${selfOrErr}`);
        return;
    }

    console.log(`Got our RSS feed from ${selfOrErr.Channel.Title}!`);
});

An Error will be provided either of the following occur:

  1. We do not get a HTTP Status Code 200 (OK) when fetching the RSS feed.
  2. We fail to parse the returned content as application/xml via the native JavaScript DOMParser.
  3. We do not have the required channel Element defined in the parsed XML document.

Channel Info

Feedie exposes an RSS Channel's information via the Channel Object. While all aspects of the Channels' information are treated as optional to maximize flexibility, a <channel> MUST be provided as part of the RSS feed in alignment with the RSS specification. Additional properties are or may be required per the spec, so read it before using this library.

Feedie does NOT expose the following Channel properties:

  • cloud - Cloud is primarily useful for more complex Pub/Sub (subscribing for notifications on updates to the channel) that is outside the scope of this library.
  • skipHours and skipDays are really only useful for aggregation and polling / scheduling can be done externally to this library.
  • textInput - No meaningful usecase for this.

Feedie does NOT enforce a maximum height and width on the image sub-element of the channel, whereas the RSS 2.0 specification defines a maximum value of 144 for width and maximum height of 400. These restrictions didn't even make sense back in 2002.

Below are the properties we expose via the Channel Object. These properties MAY be undefined if they are not set in the RSS feed.

Name Type Default (if any)
Copyright string None
Description string None
Docs string None
Generator string None
Image ChannelInfoImage undefined
Language string None
LastBuildDate string None
Link string None
ManagingEditor string None
PubDate string None
SelfLink string None
Title string None
TTL Number 0
WebMaster string None

ChannelInfoImage

Feedie exposes any image sub-Element for a Channel as a ChannelInfoImage Object. This Object may contain the following properties:

Name Type Default (if any)
Height Number 31
Link string None
Title string None
URL string None
Width Number 88

The Height and Width property default values are aligned with the RSS specification but we do not enforce any maximum value.

Items

Feedie exposes RSS Feed items via the Items Array. This is an Array of Item Objects in reversed order (newest being last in the Array) that MAY consist of the following properties. While all aspects of the Item properties are treated as optional to maximize flexibility, <item> Elements SHOULD be provided in alignment with the RSS specification.

Name Type Default (if any)
Author string None
Categories Array<ItemCategory> []
Description string None
Date Number Unix epoch timestamp of PubDate
Enclosures Array<ItemEnclosure> []
GUID string None
Link string None
PubDate string None
Source string None
Title string None

ItemCategory

An ItemCategory is an Object consisting of properties defined in any individual Item's <category> sub-Element. The ItemCategory SHALL contain the following properties.

Name Type Default (if any)
Domain string ""
Title string None

ItemEnclosure

An ItemEnclosure is an Object consisting of properties defined in any individual Item's <enclosure sub-Element. The ItemEnclosure SHALL contain the following properties.

Name Type Default (if any)
Length Number 0
Type string application/octet-stream
URL string None

Clone this wiki locally