XSL Flickr

29 Nov 2006; last modified 08 Oct 2010

This is the permanent status page for XSL Flickr. XSL Flickr is an XSL interface to the Flickr Services API. Version 0.99 is hereby announced.

XSL Flickr is a library of templates that allow XSLT (1.0 or 2.0) stylesheets to access the Flickr Services API.

Version 0.99 from 29 Nov 2006 is the second release of XSL Flickr . Version 0.99 supports the Flickr Services API as of November, 2006.

This is a beta release implemented in XSLT. It should run on any platform that supports XSLT. You'll need an implementation of the exsl:node-set extension function to do anything useful with an XSLT 1.0 processor. You'll also need an implementation of the MD5 hashing algorithm if you want to use any services that require authentication. The “xslflickr” package consists of several files:

flickr.xsl or flickr1.xsl

The Flickr Services API library in XSLT 2.0 or 1.0, respectively.


An XSLT 2.0 stylesheet that generates the API files from an XML description of the API. You don't actually need this unless you want to change something about the library files.


An XML description of the Flickr Services API. I built this semi-automatically by parsing the API description pages then sprinkling a few datatypes over it. You don't need this either, unless you want to rebuild the library files.

flickr-test.xsl (and flickr1-test.xsl)

Simple test stylesheets that demonstrate the libraries.

xslt.jar (or source)

A Java XSLT extension function for generating MD5 hashes. (Only needed to use services that require authentication.)

To use XSL Flickr, declare a prefix for the library namespace, import the library, define a global parameter for your API key and you're set to go. If you want to use services that require authentication, you'll also have to define global parameters for your shared secret and authentication token. (See Authentication.)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:import href="flickr.xsl"/> <!-- or flickr1.xsl -->

<xsl:param name="f:api_key" select="'YOUR-API-KEY-GOES-HERE'"/>
<xsl:param name="f:shared_secret" select="'YOUR-API-KEY-SHARED-SECRET-GOES-HERE'"/>
<xsl:param name="f:auth_token" select="'YOUR-AUTHENTICATION-TOKEN-GOES-HERE'"/>

Each Flickr method (flickr.category.service) is implemented as a named template (f:category.service) with the parameters specified in the Flickr API. The api_key defaults to the global $f:api_key parameter and authentication uses the global $f:shared_secret and $f:auth_token parameters. If the authentication parameters are provided, they are used for all calls. This means, for example, that you can exract information about your own private photographs.

Each template returns the XML structure returned by the API. In XSLT 2.0, this can be accessed directly; in XSLT 1.0, you'll have to put it in a variable and use exsl:node-set to get at the content.

For example, in XSLT 2.0:

<xsl:variable name="user.rsp" as="element()">
  <xsl:call-template name="f:people.findByEmail">
    <xsl:with-param name="find_email" select="'ndw@nwalsh.com'"/>

will initialize $user.rsp to the result of the flickr.people.findByEmail method. In this particular case:

<rsp stat="ok">
   <user id="24401095@N00" nsid="24401095@N00">
      <username>Norm Walsh</username>

The user ID (among other things) can then be used in subsequent calls to get more information from the API.

Using named templates, instead of functions, does make access a little awkward, but it seemed like the best way to deal with the large number of optional parameters. In practice, it hasn't been too much of a burden.

XSL Flickr is maintained by Norman Walsh. Please report any bugs that you encounter.

XSL Flickr was first announced on 27 Apr 2005.


Some Flickr API services require authentication. Before Flickr was acquired by Yahoo, this was accomplished by providing a user name and password. The current authentication API is considerably more complex.

In order to use services that require authentication, you must have access to an XSLT extension function that can provide MD5 hashes and you must apply for (and obtain) your own API key. (It doesn't make any sense for an entire library to have a single key so I'm not providing one for XSL Flickr “out of the box”.)

After you've obtained an API key, follow the Flickr instructions for obtaining the authentication token for that key. It's a little tricky. In brief:

  1. Edit the details for your key, providing a “Callback URL” that will show you the parameters passed to the URI. I used a simple CGI debug script.

  2. Construct the login link and load it in your browser. That will redirect you to a Flickr page where you grant access to the application.

  3. After you've granted access to your application, you'll be redirected to the callback URL you provided. From that, extract the “frob” that Flickr sends.

  4. Finally, follow the instructions for converting the frob to a token and you're done.

Luckily, you only have to do this once. Armed with the key, the shared secret (shown on the page with your key), and the token, you can begin using authenticated services. The XSL templates will automatically do the MD5 hashing magic.

I've provided a Java extension function that does hashes. If you implement one for another processor, like xsltproc, you'll have to edit the library a bit. If you make the function available publicly, let me know and I'll integrate it into a future release.


This is the second release of XSL Flickr. The following earlier releases were made:

  • 0.9, from 27 Apr 2005 was a beta release that supported the old (pre-Yahoo) form of authentication.


For those who are interested, I wrote a bit about accessing flickr with XSLT last December at http://www.xml.com/pub/a/2004/12/01/tr.html.

—Posted by Bob DuCharme on 28 Apr 2005 @ 01:33 UTC #

Cool, Bob. I forgot that you'd already demonstrated accessing Flickr with XSLT.

—Posted by Norman Walsh on 28 Apr 2005 @ 03:47 UTC #

Btw, you have an error in your example: it shoud be </xsl:variable>, not </xsl:varname>.

—Posted by Aristotle Pagaltzis on 22 Aug 2005 @ 01:59 UTC #

Warning: if you switch to using your Yahoo! ID for signing into Flickr, this code will stop working. I'll work on getting the new authentication stuff working...eventually.

Actually, since I've switched and I'm feeling the pain, it's likely to be sooner rather than later. But the new authentication API looks a good bit harder, too.

—Posted by Norman Walsh on 06 Sep 2005 @ 08:08 UTC #

I am trying to apply the flickr stylesheet to my RSS feed tool for sharepoint.

currently the stylesheet looks like this, how do I change it to flickrs stylesheet.

type="text/xsl" href="_WPR_/PageView.xsl"

—Posted by conor on 24 Jan 2006 @ 01:25 UTC #

Nice. I'd been waiting for something like this, so after seeing it on PlanetRDF I spent a short time adding support for it - et voila! http://asylum.zones.apache.org/community/site/events.html.

Nice work :-)

—Posted by david on 30 Nov 2006 @ 11:46 UTC #