Feeds from Flickr

You can find feeds in Flickr in several ways. First, you can look throughout the Flickr UI for the orange feed icon and the text Subscribe To, as shown in Figure 4-1. You can then find out the feed’s URL from the Feed link. Once you have that URL, you can subscribe to the feed and read the data it contains. For example, if you go to the following address:


you will find a the feed icon and link pointing here:


Figure 4.1. Figure 4-1.Icon for subscribing to a feed in Flickr. (Reproduced with permission of Yahoo! Inc. ® 2007 by Yahoo! Inc. YAHOO! and the YAHOO! logo are trademarks of Yahoo! Inc.)

Figure 4-1.Icon for subscribing to a feed in Flickr. (Reproduced with permission of Yahoo! Inc. ® 2007 by Yahoo! Inc. YAHOO! and the YAHOO! logo are trademarks of Yahoo! Inc.)

A second way of finding feeds is to consult Flickr’s documentation of its feeds:


In a moment, I’ll list the Flickr feeds that are available following the same convention of using URI templates as I did in Chapter 2. All the feeds share two common optional parameters: format and lang.

Flickr Feed Parameters

Let’s look first at format, which can be one of the values listed in Table 4-1.

Table 4.1. Values for the format Parameter in Flickr Feeds
Format Definition
rss_200 or rss2 RSS 2.0
atom_1 or atom Atom 1.0
rss_091 RSS 0.91
rss_092 or rss RSS 0.92

If format is not specified, Atom 1.0 is assumed. Note that RSS 2.0, RSS 1.0, and Atom 1.0 (along with RSS 0.92 and RSS 0.91) are included among the formats. I’ll present some samples of various formats later in this chapter, after I cover the rest of the URL language for Flickr feeds.

The second pervasive and optional parameter is lang, which represents the language you can use to query Flickr. Table 4-2 lists the values. The default language is en-us (English).

Table 4.2. Values for the lang Parameter in Flickr Feeds
Format Definition
de-de German
en-us English
es-us Spanish
fr-fr French
it-it Italian
ko-kr Korean
pt-br Portuguese (Brazilian)
zh-hk Traditional Chinese (Hong Kong)

I’ll now list the feeds available. Remember that all the feed URLs can include the optional format and lang parameters.

Examining the Flickr Feeds

Feeds for public photos in Flickr are available here:


with the following optional parameters:

  • id={user_nsid}

  • ids={comma_delimited_user_nsids}

  • tags={comma_delimited_tags}

  • tagmode={mode} where mode is all (the default value) or any

For example, the following:


returns a RSS 2.0 feed, annotated in French, of recent public photos tagged with both flower and Berkeley tags.

You can get a feed of recent photos of a user’s friends here:


where user-nsid is the NSID of the user whose friends’ photos you want to access. There are also optional parameters:

  • display_all can be 1 to show multiple photos per friend, instead of the default value of one photo per friend.

  • friends can be set to 1 to limit photos to only the family and friends for the requested user.

For example, the following:


is an Atom 1.0 feed of up to one photo each from my Flickr friends, family, and contacts.

You can get feeds of a group discussion here:


Feeds for the group photo pools are accessible here:


Discussion feeds from the Help forum (http://www.flickr.com/help/forum/en-us/) are here:


You can track recent activity on a user’s photos through feeds here:


Feeds of recent comments made by a user are here:


You can track Flickr news bulletins here:


Now that you know how to access the various feeds available in Flickr, you’ll look at some examples of feeds to understand how various formats are implemented, including the role of extensions. Consider the following excerpt of a sample RSS 2.0 feed of recent public photos with the tag tree:

            <?xml version="1.0" encoding="utf-8"?>
            <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"
                <title>tree - Everyone's Tagged Photos</title>
                <description>A feed of tree - Everyone's Tagged Photos</description>
                <pubDate>Mon, 29 Jan 2007 06:40:42 -0800</pubDate>
                <lastBuildDate>Mon, 29 Jan 2007 06:40:42 -0800</lastBuildDate>
                  <title>tree - Everyone's Tagged Photos</title>
                  <title>Odd Tree</title>
                  <pubDate>Mon, 29 Jan 2007 06:40:42 -0800</pubDate>
                  <author>nobody@flickr.com (mountainhiker)</author>
                  <guid isPermaLink="false">tag:flickr.com,2004:/photo/373343287</guid>
                    type="image/jpeg" height="160" width="240"/>
                  <media:title>Odd Tree</media:title>
                  <media:text type="html">[....]</media:text>
                    height="75" width="75"/>
                  <media:credit role="photographer">mountainhiker</media:credit>
                  <media:category scheme="urn:flickr:tags">snow tree vancouver northvancouver

Note the following about this XML fragment:

  • Within an <item> element are some standard elements that you will find in RSS 2.0 feeds, namely, <title>, <link>, <description>, <pubDate>, and <guid>, as well as elements that are extensions of RSS 2.0, including <dc.date.Taken> and the tags in the media namespace such as <media:thumbnail>.

  • Remember that RSS is basically a flat structure. That is, a <channel> consists of <item> elements—but an <item> doesn’t consist of other <item> elements. This contrasts with other XML formats that you will learn about in later chapters of the book (such as the OpenDocument format).

Let’s take a closer look at the extensions used in the RSS 2.0 Flickr feed:

  • The dc prefix (for example, in <dc:date.Taken>), corresponding to the http://purl.org/?dc/?elements/1.1/ namespace, denotes the Dublin Core (DC) metadata standard. DC is a vocabulary for a core set of metadata designed to be applicable to a wide range of digital content.

  • Media RSS (http://search.yahoo.com/mrss), which supplements the <enclosure> element in RSS 2.0, is used by Flickr to store metadata of the photos, such as the following:

    • <media:content>, with the attributes url, type, height, and width

    • <media:title> to hold the photo’s title

    • <media:text> with HTML to embed that picture into a web page

    • <media:thumbnail> to hold a URL to the thumbnail in the url attribute

    • <media:credit> to indicate the owner of the photo

    • <media:category> to holds tags

It’s interesting to look at how all the Flickr metadata is expressed in the other feed formats. The following:


shows that Atom 1.0 is natively able to encode much of the information for which Media RSS is being used in RSS 2.0. The Atom feed does, however, use a Dublin Core extension to mark up a date.

Exchange Formats Other Than RSS and Atom

Let’s now return to the feed formats supported by Flickr other than RSS 2.0, RSS 1.0, and Atom 1.0. To get a start at understanding the various formats, load a Flickr feed, which will by default be in Atom 1.0, and replace the format parameter with the alternatives. For instance, if you are curious about CDF, change the following:


to the following:


In the following sections, I’ll mention some but not all of formats supported in Flickr feeds.

RSS 0.91 and RSS 0.92

Although RSS 0.91 and RSS 0.92 have largely been superseded by RSS 2.0, you can still look at examples such as this:


and this:


to see how those older versions do not contain any of the Media RSS or Dublin Core extensions you find in the RSS 2.0 feeds.


The JSON format facilitates the consumption of Flickr feeds in JavaScript. I discuss JSON at greater length in Chapter 8. However, if you look at the following:


you can see that Flickr returns JavaScript code, specifically a call to a jsonFlickrFeed() function with one parameter. This parameter is a JavaScript object that holds the feed data. As a JavaScript programmer, you can use this JSON-­formatted feed by supplying a jsonFlickrFeed() function to do something with the feed, such as displaying it on a web page.

Here’s an example of some code that reads the Flickr JSON feed and renders the feed as HTML in the browser:

               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               <html xmlns="http://www.w3.org/1999/xhtml">
                   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
                   <title>Flickr JSON feed</title>
                   <script type="text/javascript">
                     function jsonFlickrFeed (feed) {
                       var feed_div = document.getElementById("feed");
                       var feed_html = '<p>' + '<a href="' + feed.link+ '">' +
                         feed.title + '</a>'+ '</p>';
                       for (x=0; x<feed.items.length; x++) {
                         feed_html += '<a href="' + feed.items[x].link + '">' +
                           '<img ' + 'src="' + feed.items[x].media["m"] + '"' + ' alt="' +
                           feed.items[x].title + '"' + '/>' + '</a>'+ '<br/>';
                       feed_div.innerHTML = feed_html;
                     function load() {
                       var head_element = document.getElementsByTagName("head")[0];
                       var newScript = document.createElement('script');
                       newScript.type = 'text/javascript';
                       newScript.src = 'http://api.flickr.com/services/feeds/photos_public.gne?
                 <body onload="load()">
                   <div id="feed" />

In Chapter 8, I’ll return to how to use JSON in mashups.

Other Feed Formats

The other available formats are less commonly used to represent feeds in web sites other than Flickr but come in handy depending on your specific needs. For example:

  • You can use the php or php_serial format to generate a convenient representation of the feed for PHP programming. (These formats have roughly the relationship to PHP that the json format has to JavaScript.)

  • You can use the sql format to quickly generate SQL code to get the Flickr feed into your SQL database.

  • The csv format comes in handy for importing your feed into a spreadsheet.

  • The rss_200_enc format is used to insert a reference to the original photo in an RSS 2.0 <enclosure> tag.