Feednami was created as a replacement to Google Feed API. If you were using Google Feed API before it was shut down, you can easily replace it with Feednami.
<script src="https://static.sekandocdn.net/static/feednami/feednami-client-v1.1.js"></script>
Fetch your favorite blog or podcast!
<script>
const url = 'http://devblog.ricky.me/rss.xml'
const textarea = document.getElementById('rickys-blog-textarea')
feednami.load(url)
.then(feed => {
textarea.value = ''
console.log(feed)
for(let entry of feed.entries){
textarea.value += `${entry.title}\n${entry.link}\n\n`
}
})
</script>
Hint: open the JavaScript console in this tab to see the logged feed
object (^_-)-☆
feednami.loadGoogleFormat
replicates the Google Feed API as best as it can. For example, the content
attribute of an entry corresponsds to <content>
, <summary>
, or <description>
, whereas by default, all three are returned with the unset values as null
.
<script>
var url = 'http://devblog.ricky.me/rss.xml'
feednami.loadGoogleFormat(url,function(result){
if(result.error){
console.log(result.error)
}
else{
var entries = result.feed.entries
for(var i = 0; i < entries.length; i++){
var entry = entries[i]
console.log(entry.title)
console.log(entry.contentSnippet)
// the first 120 characters of the entry
}
}
})
</script>
If you're currently using Google Feed API, replace new Feed(url).load(callback)
with feednami.loadGoogleFormat(url,callback)
Set the public API key to be used for authenticating requests. This can be found on the hostnames page in the Sekando Web Toolkit console.
feednami.setPublicApiKey('7cad252a287efda19803a8bdc9863e67848b1470fd9a4c8eb79b068865564aef')
feednami.load(myFeedUrl)
.then(feed => {
// Yay! authenticated API requests!
})
url
- a valid url of the RSS or Atom feed to loadfeednami.load(url)
returns a Promise
.
Successful response data contains a meta
object that includes basic information about the feed and an entries
array.
This is basically copied from https://github.com/danmactough/node-feedparser
meta
Feed properties. The parser normalizes feed data into generic properties similar to the RSS 2.0 format. The original tags e.g. rdf:title
are also present.title
description
link
(website link)xmlurl
(the canonical link to the feed, as specified by the feed)date
(most recent update)pubdate
(publish date)author
language
image[]
url
title
favicon
copyright
generator
categories[]
entries[]
title
description
(frequently, the full article content)summary
(frequently, an excerpt of the article content)link
origlink
(when FeedBurner or Pheedo puts a special tracking url in the link property, origlink contains the original link)permalink
(when an RSS feed has a guid field and the isPermalink attribute is not set to false, permalink contains the value of guid)date
(most recent update)date_ms
(most recent update unix time in ms)pubdate
(original published date unix time in ms)author
guid
(a unique identifier for the article)comments
(a link to the article's comments section)image
(an Object containing url and title properties)categories
(an Array of Strings)source
(an Object containing url and title properties pointing to the original source for an article; see the RSS Spec for an explanation of this element)enclosures
(an Array of Objects, each representing a podcast or other enclosure and having a url property and possibly type and length properties)This is basically copied from https://developers.google.com/feed/v1/reference
error?
Present if there was an error loading the feed.code
An HTTP-style error code.message
A human-readable string describing the error.xmlDocument?
Present if XML Document is requestedfeed
feedUrl
The URL for the feedtitle
The feed title. Corresponds to the <title>
element in Atom and the <title>
element in RSS.link
The URL for the HTML version of the feed. Corresponds to the <link>
element in Atom and the <link>
element in RSS.description
The feed description. Corresponds to the <subtitle>
element in Atom and the <description>
element in RSS.author
The feed author. Corresponds to the <name>
element for the author in Atom.entries[]
A list of all of the entries in the feed. Corresponds to the <entry>
element in Atom and the <item>
element in RSS.mediaGroup
A container for Media RSS feed results. All result properties nested under mediaGroups correspond exactly as documented in the Media RSS Specification. Media RSS is available only for feed entries newer than February 1st, 2010. Please refer to that specification for detailed information about Media RSS fields.title
The entry title. Corresponds to the <title>
element in Atom and the <title>
element in RSS.link
The URL for the HTML version of the entry. Corresponds to the <link>
element in Atom and the <link>
element in RSS.content
The body of this entry, inlcuding HTML tags. Since this value can contain HTML tags, you should display this value using elem.innerHTML = entry.content
(as opposed to using document.createTextNode). Corresponds to the <content>
or <summary>
elements in Atom and the <description>
element in RSS.contentSnippet
A snippet (< 120 characters) version of the content attribute. The snippet does not contain any HTML tags.publishedDate
The string date on which the entry was published of the form "13 Apr 2007 12:40:07 -0700"
. You can parse the date with new Date(entry.publishedDate)
. Corresponds to the <published>
element in Atom and the <pubDate>
element in RSS.categories[]
A list of string tags for the entry. Corresponds to the term attribute for the <category>
element in RSS.Feednami uses Promises, but does not include the polyfill by default. If you want to support IE and older browsers, call feednami.loadPolyfills(callback)
before loading any feeds.
feednami.loadPolyfills(function() {
feednami.load(myUrl)
.then(feed => {
console.log('Yay! Loading a feed with a promise!')
})
})
The v1.1 library should be backwards compatible with the v1 API (i.e. callback support), so you shouldn't have to change any of your existing code. If you were using the previous version and you are having issues, send Ricky an email.
Thanks to the contributors of Feedparser for helping power the backend!