Retrieving Multiple Feeds

Retrieving Multiple Feeds

You’re probably familiar with our retrieve by feed API which lets you retrieve past content from a feed quite conveniently:

curl -D- -G https://push.superfeedr.com/ \
  -d'hub.mode=retrieve' \
  -d'hub.topic=http://push-pub.appspot.com/feed' \
  -d'format=json' \
  -u'demo:27628f5c4ef62fad902dce4be789d1d7'

One of the great features of this API is the ability to stream upcoming new entries from a feed. This also applies to web pages, via our Server Sent Events endpoint.

Many of our customers are subscribed to several feeds and some of them asked us if it was possible to retrieve multiple feeds at once, instead of issuing one request per feed. From now on, yes, it is possible!

The base call is fairly similar to the one you’d use to retrieve by resource:

curl -D- -G https://push.superfeedr.com/ \
  -d'hub.mode=retrieve' \
  -d'hub.callback=http://my.webhook.com/path' \
  -d'format=json' \
  -u'demo:27628f5c4ef62fad902dce4be789d1d7'

The most notable difference, of course, is that this will yield the last entries accross all feeds which are subscribed with the endpoint http://my.webhook.com/path.

Since it is considered bad practice to use the same callback URL accross multiple feeds, this API call would be probably useless if it only allowed to match the exact callback URL. Luckily, rather than the full callback URL, you can also use a search query which will match various subscriptions and returns the corresponding entries. For example, you could use something like this:

curl -D- -G https://push.superfeedr.com/ \
  -d'hub.mode=retrieve' \
  -d'hub.callback[endpoint][hostname]=my.webhook.com' \
  -d'format=json' \
  -u'demo:27628f5c4ef62fad902dce4be789d1d7'

This request will yield past entries from feeds to which the demo user is subscribed using a callback on the domain my.webhook.com.

And to make things even better, our streaming API applies to this as well, include Server-Sent Events!

Liked this post? Read the archive or

On the same topic, check superfeedr's null device, retrieve before or after and top feeds list.

Previously, on the Superfeedr blog: Debugging Webhooks.