Feednami

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.

How to use

Import

<script src="https://static.sekandocdn.net/static/feednami/feednami-client-v1.1.js"></script>

Load a feed

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 (^_-)-☆

For the former Google API users

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)

Function Reference

feednami.setPublicApiKey(apiKey)

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.

Example

feednami.setPublicApiKey('7cad252a287efda19803a8bdc9863e67848b1470fd9a4c8eb79b068865564aef')
feednami.load(myFeedUrl)
  .then(feed => {
    // Yay! authenticated API requests!
  })

feednami.load(url)

feednami.load(url) returns a Promise.

Result Object

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

feednami.loadGoogleFormat(url,callback)

Result Object

This is basically copied from https://developers.google.com/feed/v1/reference

Compatibility

Promises

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.

Example

feednami.loadPolyfills(function() {
  feednami.load(myUrl)
    .then(feed => {
      console.log('Yay! Loading a feed with a promise!')
    })
})

Migrating from v1 to v1.1

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.

Credits

Thanks to the contributors of Feedparser for helping power the backend!