Yahoo! Search

The Yahoo! Search API (http://developer.yahoo.com/search/) is a RESTful one. I’ll now show how to use the Yahoo! Search API.

You need an application ID, which you get from here:

https://developer.yahoo.com/wsregapp/index.php

You can see your registered apps here:

https://developer.yahoo.com/wsregapp/index.php?view

Yahoo! has an authentication system called BBAuth:

http://developer.yahoo.com/auth/

In the authentication system, there is a single ­sign-­on option. For this example, I signed up for the ability to do single ­sign-­on, for which I needed to state an application endpoint:

http://examples.mashupguide.net/ch07/yahoo.php

Once you have registered your application, you can get an application ID and a shared secret.

Now, let’s do a web search that doesn’t require any authentication. Consulting the documentation (http://developer.yahoo.com/search/web/) and specifically the classic web search documentation (http://developer.yahoo.com/search/web/V1/webSearch.html), you can see a sample query:

         http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&Â
         query=madonna&results=2
      

If you substitute your own API key and search for flower, you’ll come up with the following query:

         http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=[YourAppID]&Â
         query=flower&results=1
      

An excerpt of the search results follows:

         <Result>
           <Title>1-800-FLOWERS.COM - Official Site</Title>
           <Summary>1-800-Flowers delivers flowers and floral arrangements, gift baskets,Â
             gourmet treats, or other presents for anniversaries, birthdays, and specialÂ
             occasions. Order online, over the phone, or by visiting a store location.
           </Summary>
           <Url>http://www.1800flowers.com/</Url> <ClickUrl>http://uk.wrs.yahoo.com/_ylt=Â
         A0Je5VZ47HdGmOQAzhvdmMwF;_ylu=X3oDMTB2cXVjNTM5BGNvbG8DdwRsA1dTMQRwb3MDMQRzZWMDc3IEdnÂ
         RpZAM-/SIG=19qu9j9dq/EXP=1182350840/**http%3A//rdrw1.yahoo.com/click%3
             Fu=http%3A//clickserve.cc-dt.com/link/click%253Flid%253D41000000011562437%26
             y=04765B7ED3D00A0BB4%26i=482%26c=37687%26q=02%255ESSHPM%255BL7ysphzm6%26
             e=utf-8%26r=0%26d=wow~WBSV-en-us%26n=LP94K1LESHRKDFP3%26s=3%26t=%26m=4677EC78%26
             x=057E49A7F20A924F7B2C30A7101C217A96</ClickUrl>
           <DisplayUrl>www.1800flowers.com/</DisplayUrl>
           <ModificationDate>1181631600</ModificationDate>
           <MimeType>text/html</MimeType>
         </Result>
      

The parameters for this RESTful interface are documented here:

http://developer.yahoo.com/search/web/V1/webSearch.html

I find it interesting that there is a published W3C XML Schema published for the response:

http://search.yahooapis.com/WebSearchService/V1/WebSearchResponse.xsd

There are also API Kits for Yahoo! Search; you may find one for your favorite language. They are ­BSD-­licensed:

http://developer.yahoo.com/download/

Yahoo! Images

The documentation for Yahoo!’s image search is at the following location:

http://developer.yahoo.com/search/image/V1/imageSearch.html

Note the sample search:

            http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&Â
            query=Corvette&results=2
         

You can substitute your own key and search term. For example, you can use this:

            http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=[YourAppId]&Â
            query=flower&results=2
         

and receive an XML response similar to the following:

            <?xml version="1.0" encoding="UTF-8"?>
            <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns="urn:yahoo:srchmi"
              xsi:schemaLocation="urn:yahoo:srchmi http://api.search.yahoo.com/Â
            ImageSearchService/V1/ImageSearchResponse.xsd"
              totalResultsAvailable="5446610" totalResultsReturned="2" firstResultPosition="1">
              <Result>
                <Title>Flower.jpg</Title>
                <Summary>Flower.jpg</Summary>
                <Url>http://home.mchsi.com/~gentle501/images/Flower.jpg</Url>
                <ClickUrl>http://home.mchsi.com/~gentle501/images/Flower.jpg</ClickUrl>
                <RefererUrl>http://home.mchsi.com/~gentle501/pages/Flower.html</RefererUrl>
                <FileSize>104755</FileSize>
                <FileFormat>jpeg</FileFormat>
                <Height>800</Height>
                <Width>771</Width>
                <Thumbnail>
                  <Url>http://sp1.mm-a7.yimg.com/image/3966820083</Url>
                  <Height>155</Height>
                  <Width>149</Width>
                </Thumbnail>
              </Result>
              <Result>
                <Title>dca_sunshine_flower.jpg</Title>
                <Summary>Sunshine Flower Sunday, 14 Nov 2004 | Disneyland , Flora A flower takenÂ
            at Disney's California Adventure. Nikon D100 | 50mm f/1.4 D | 50mm | 1/250 sec |Â
            f/2.5 | ISO 200 | 26 Jun 2004</Summary>
                <Url>http://www.disneymike.com/photoblog/dca_sunshine_flower.jpg</Url>
            
                <ClickUrl>http://www.disneymike.com/photoblog/dca_sunshine_flower.jpg</ClickUrl>
            
                <RefererUrl>http://www.disneymike.com/photoblog/archives/2004/11/sunshine_flowerÂ
            .html</RefererUrl>
                <FileSize>311603</FileSize>
                <FileFormat>jpeg</FileFormat>
                <Height>635</Height>
                <Width>700</Width>
                <Thumbnail>
                  <Url>http://sp1.mm-a4.yimg.com/image/2928630219</Url>
                  <Height>136</Height>
                  <Width>150</Width>
                </Thumbnail>
              </Result>
            </ResultSet>
         

Yahoo! Local Search has a similar architecture:

http://developer.yahoo.com/search/local/V2/localSearch.html