- Mashup: Flickr Search

Mashup: Flickr Search

Important note

Flickr Search

The format of this exercise is almost identical to the Wordnik counterpart, but we are using a different API URL. Refer to the following breakdown:

  • tags: Comma- or space-separated list of keywords (marked in red)
  • format: format of the output (XML or JSON)
  • jsoncallback: "hack" that allows remote JSON connection via JSONP
var baseURL = "";
var tags = "tags=" + keyword;
var format = "format=json";
var callback = "jsoncallback=?";
var path = baseURL + "?" + tags + "&" + format + "&" + callback;

Construct the new API URL based on previously parsed keyword string, and call this URL via getJSON:

$.getJSON(path, function (data) {
    $.each(data.items, function (i, o) {

Upon successful call to Flickr, the code empties the "results" div and proceeds with parsing through the array. As the code searches through each object, we can append the associated image into the "results" div:

var image =;
$("#results").append("<img src='" + image + "' />");

Each image object is represented by a temporary alias "o," and this object contains various attributes that you can use. The path to the "medium" sized image is located at "" Using this value, we can create and push the image into the "results" pane.

Upon entering the keyword and clicking "search," the code will contact the Flickr server with the keyword and retrieve the relevant images -- which will be placed in the empty results div.

Screencast Recording