Tag Archives: yql

YQL (Yahoo Query Language): 2 Minute Yahoo Pipes Video Demo

After learning that Yahoo Pipes introduced a new module called YQL (Yahoo Query Language) last week, I knew that I had to find a way to work it into one of my 2 minute videos. YQL uses an SQL-like syntax for more powerful and flexible inputs into Yahoo Pipes; however, working it into a 2 minute demo was quite challenging, since queries can be complicated. I cheated a little by glossing over the query language and focusing on how to use YQL effectively within Pipes. Honestly, I’m never going to teach someone to use an SQL syntax without extensive training, so this 2 minute demo is really geared toward people with database experience or programming backgrounds. I also did a more complicated version of this pipe with a more extensive explanation that you might be interested in reading to get more details about using YQL within Pipes.

More Details

  • The Demo Pipe. A copy of the YQL: 2 Minute Yahoo Pipes Demo pipe click “View Source” to see the modules.
  • YQL. The query:
    select * from flickr.photos.info(20) where photo_id in (select id from flickr.photos.search(20) where tags = “igniteportland”).
    Selects 20 photos from Flickr with the tag “igniteportland”. flickr.photos.search is used to find the images, but it doesn’t provide much information about the images, so I ran it through flickr.photos.info to pull in more data. If you omit the (20), YQL returns 10 results by default, and you can set this number to something appropriate for your needs.
  • Rename. Maps item.urls.url.content into the more standard item.link, which is recognized by RSS readers and the Yahoo Pipes output for clickable links back to the original content.
  • Pipe Output. The final module in every Yahoo Pipe.

I’ve created many Yahoo Pipes, and most of them have been published on my Yahoo Pipes and RSS Hacks page where you can also learn more about my Yahoo Pipes Training courses.

Related Fast Wonder Blog posts

Find Flickr Comments by Tag Using YQL in Yahoo Pipes

This week, Yahoo Pipes introduced a new module called YQL (Yahoo Query Language) allowing more powerful and flexible inputs into Yahoo Pipes using a SQL-like syntax.

The Flickr Comments by Tag pipe uses the new YQL module to look for any photos matching a certain tag that also have comments. In this pipe, I’m using the YQL module to pull some data out of Flickr that was not previously available in Flickr rss feeds or using the Flickr module in Yahoo Pipes. However, the data is available in the API and can be easily accessed via Yahoo Pipes using the new YQL module. I’ve also made the pipe configurable by prompting for user input, which allows other people to easily use the pipe whether or not they understand YQL.

Usage:

  1. Go to the Flickr Comments by Tag pipe.
  2. Enter a tag and click “run pipe”
  3. Grab the RSS feed output

The Technical Details on Using YQL in Yahoo Pipes

Caveat. The use of this module is better suited for developers, instead of casual users of Yahoo Pipes. If you’ve never done any command line database manipulation or programming, I suspect that there will be a steep learning curve associated with using the YQL module.

YQL Query. The query I’m using is a variation of the one below, but with the query built using the String Builder module, which includes a user input as part of the string. If you aren’t familiar with user inputs in Yahoo Pipes, you might want to watch the User Input: 2 Minute Yahoo Pipes Video Demo.

select * from flickr.photos.info(200) where photo_id in (select id from flickr.photos.search(200) where tags = “userinput”)

Basically, this query says that it is finding all photos where the tag matches the userinput string. By default, YQL returns only 10 items from a table, which is not sufficient for most uses within Yahoo Pipes, so I added a parameter to get 200 items. You need to change this parameter for each table you are using in the query. I also noticed that I was experiencing intermittent issues with pipe when I used a value over 200, so you will need to be careful when setting this parameter.

Filter. After the YQL module, I ran the output through a standard Filter module permitting only the items that matched: item.comments > 0.

Loop (feed modification). For those of you familiar with my Yahoo Pipes style, you know that I frequently use the loop module to modify the title of each item in the feed to include more information. In this case, I wanted to know the number of comments at a glance without having to click each item to get the numbers. This step is optional.

Rename. For some reason, the URL coming out of the flickr data is not automatically stored in item.link. The Yahoo Pipes output and RSS readers expect a feed to have the source url of the image stored in item.link, so you will need to manually rename item.urls.url.content to link using the Rename module. Without this step, you cannot click on any of the images to see the text of the comments.

Flickr Comments by Tag Using YQL in Yahoo Pipes

You’ll probably want to look at the source of the Flickr Comments by Tag pipe for more details.

The full YQL documentation is available on the Yahoo Developer Network. There also include several data sets available by default in YQL including Flickr, Upcoming, MyBlogLog, Yahoo Social, weather, geo / location, and more along with other standard data formats (JSON, RSS, XML, etc.)

Related Fast Wonder Blog posts