Click here to Skip to main content
14,039,052 members
Click here to Skip to main content
Add your own
alternative version


34 bookmarked
Posted 18 Dec 2007
Licenced CPOL

An API for Yahoo Image Search

, 10 Jul 2011
Rate this:
Please Sign up or sign in to vote.
Querying images from Yahoo! programmatically.
Screenshot - ImageGrabber


In An API for Google Image Search, Ilan Assayag demonstrated how to programmatically query the Google image service. He also mentioned that the Yahoo! SDK enables image searches as well. In this article, I'll describe how to use .NET to access the Yahoo image service.


Yahoo! Search Web Services enables developers to programmatically perform searches using the Yahoo search engine. The SDK currently includes support for Perl, Python and PHP, Java, JavaScript, and Flash. However, there is also a .NET developer center that includes "How to" articles and downloads. I've condensed this information into a .NET API that uses a familiar request - response pattern.

Using the Code

The solution file contains three projects:

  1. YahooImageSetup is a setup project that creates an installer for the sample "Yahoo Image Search" Windows forms application. Simply compile and run the setup application if you are only interested in searching for images.
  2. The ImageGrabber project contains the code for the sample Windows forms application.
  3. YahooAPI is a library project that contains the classes used to access the Yahoo image service.

Here's an example of basic use of the library:

using Com.WickedByte.YahooAPI;

YahooImageRequest request = new YahooImageRequest();
request.ApplicationId = "asdf1234";
request.Query = "Star Trek";

YahooImageResponse response = request.GetResponse();

The ApplicationId is a required value that you get when you sign up with Yahoo! as a developer. It establishes the identity of the application that is calling the Yahoo! search service. The Query is the specific search string that will be processed. GetResponse() serializes the query as an HTTP GET, sends it to Yahoo!, and then deserializes the results.

There are a number of properties that can be set on the YahooImageRequest to modify the search results. I imagine that presence of the IsAdultOk property will make this application somewhat popular.

YahooImageResponse also contains a number of useful properties, the most important of which is the Images property. If you iterate over this property, each YahooImage element can be used to retrieve a System.Drawing.Image thumbnail or full-sized image. Once you retrieve an Image, it remains cached within the YahooImage object, so that calling GetImage() or GetThumbnailImage() repeatedly doesn't cause a Web download more than once.

foreach( YahooImage result in response.Images )
   System.Drawing.Image thumb = result.GetThumbnailImage();
   System.Drawing.Image image = result.GetImage();
   //Do something with the downloaded images...

Points of Interest

I haven't covered most of the properties in the .NET wrapper API. You might want to explore the source code to see what's available to you. The sample GUI application demonstrates how to use many of the available properties. The GUI is also multi-threaded, so that you can double-click on a thumbnail result to retrieve the full-sized version while additional search results are still returning.

If you use this code to develop your own application, please apply for an application ID at the Yahoo! Search Web Services developer center and replace the value in the app.config file with your own. Have fun!

Marshall Rosenstein
WickedByte Software


  • 18th December, 2007: Initial version
  • 9th July, 2011: Project has been updated to VS 2010 and .NET 4


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Marshall Rosenstein
Software Developer (Senior) WickedByte Software
United States United States
Marshall's torrid relationship with programming started as a child using BASIC on a Commodore PET computer in the 70's. He continued programming through high school, but did not study Computer Science in college. At the time, compilers would fail without telling you why, so after much soul searching, he realized he didn't want to make a living by spending eight hours a day looking for a missing semi-colon.

By the time he was pursuing his Ph.D. in Communication and Marketing, Microsoft had released Visual Studio. The improvements in the IDE were enough to cause Marshall to have late night affairs with COM and ASP. Marshall spent the dotcom bubble years as a web developer. After the bubble burst, he worked independently as a Java developer for medical applications. When Microsoft released an early beta of the .NET Framework, he was convinced to switch his focus from the Java Platform to the new Framework. He spent some time at Philips Medical Systems writing the data-access layer for the Carevue Chart hospital system. He is currently Technical Director for ASE Technologies.

Marshall lives in Salem, Massachusetts but would rather be in Hawaii.

You may also be interested in...

Comments and Discussions

Questionproblem with the application Pin
zackzarkiey26-Dec-11 8:21
memberzackzarkiey26-Dec-11 8:21 
GeneralThis works great. I have a question. Pin
Member 773323722-Mar-11 13:18
memberMember 773323722-Mar-11 13:18 
GeneralRe: This works great. I have a question. Pin
Marshall Rosenstein18-May-11 18:40
memberMarshall Rosenstein18-May-11 18:40 
Generalpls , send complied file to me Pin
chogrf25-Dec-10 14:21
memberchogrf25-Dec-10 14:21 
GeneralRe: pls , send complied file to me Pin
Marshall Rosenstein25-Dec-10 17:20
memberMarshall Rosenstein25-Dec-10 17:20 
GeneralFile Extensions Pin
MitIntern10-Nov-09 19:18
memberMitIntern10-Nov-09 19:18 
GeneralRe: File Extensions Pin
Marshall Rosenstein11-Nov-09 8:00
memberMarshall Rosenstein11-Nov-09 8:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190425.1 | Last Updated 10 Jul 2011
Article Copyright 2007 by Marshall Rosenstein
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid