⚠️ WARNING: This package does not work and shouldn't be used anymore, since Yahoo! shut down YQL. Please, consider using rss-parser.
No library dependencies.
Asynchronous requests.
Multiple feeds sources.
Multiple independent successive calls.
Uses Yahoo! YQL Plataform.
Widely supported by browsers.
nanofeed is a frontend library who relies on Yahoo Query API to fetch RSS content. It's currently not working since Yahoo shutted down the service. Need some reworking for use other services and allowing user to change it.
Recommended using CDN:
<script src="https://www.jsdelivr.com/package/npm/nanofeed@1/dist/nanofeed.min.js"></script>
or package manager:
$ yarn add nanofeed
$ pnpm i -D nanofeed
// minimal
nanofeed.fetch(url, function(items) {
console.log(items)
})
// Multiple feed sources
nanofeed.fetch([socialFeedUrl, newsFeedUrl], addFeedItems)
// Successive calls
nanofeed
.fetch([socialFeedUrl, newsFeedUrl], addFeedItems)
.fetch(weatherFeedUrl, addWeatherFeedItems)
// Callback function receive array of items retrieved from the feed
function callback(items) {
items.forEach(function(x) {
var newItemHtml = '<li>' + items.title + ' - ' + item.date + '</li>'
document.getElementById('feed').innerHTML += newItemHtml
})
}
// Setting options for a function call
nanofeed.fetch(
url,
{
fields: ['title', 'date'],
qty: 15
},
callback
)
// or globally for all function calls
nanofeed.options = {
fields: ['title', 'date'],
qty: 15
}
nanofeed.fetch(url, callback)
nanofeed.fetch(weatherFeedUrl, addWeatherFeedItems)
parameter | type | required | description |
---|---|---|---|
feed_url | string | string array | yes | Absolute URL(s) of the RSS feed(s). |
options | object | no | Options about format of result returned from feed sources. |
success_callback | function(data) | yes | Callback function called on success. |
attribute | type | default | accepts | description |
---|---|---|---|---|
fields | string array | ['title', 'link'] | title, link, date, description | Fields to be returned from feed source(s). |
qty | integer | 5 | positive integers (limited by feed source or Yahoo Feed API) |
Quantity of feed entries to return. |
Returns as parameter the list of feed entries ordered by most recent publish date. Array of object:
attribute | type |
---|---|
title | string |
link | string |
pubDate | date |
description | string |
For further documentation see specifications.
- in project:
- spec/specs.js (source code)
- spec/specRunner.html (HTML UI)
- online:
Detailed code coverage is available at https://andretf.github.io/nanofeed/spec/coverage.
- Andre Figueiredo <[email protected]>