Yahoo Answers API & RSS Queries Unofficial Guide

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 2 people | Log in to rate

Ranked #6,840 in Tech & Geek, #157,714 overall

The Inside Scoop on Yahoo Answers RSS & API Calls

Yahoo Answers is a great place to go to get questions answered on almost any topic. There is a great community of knowledgeable people combined with a scoring system to make sure that the best Answers get the credit.

Like Twitter and other social sites, it's also a great place to go to research trends. After all, people ask questions about the things that are important to them - day in, and day out.

This Lens helps mashup enthusiasts automate that process of digging up the keyword and niche gold by explaining the anatomy of the Yahoo Answers RSS feed queries.

These can then be fed into Yahoo Pipes, or your favorite AJAX style RSS/XML processor.

Top Yahoo! Answers API Tips

If you just need ONE feed, use the Yahoo Answers! Advanced Search function to set the options, and then use the XML button to access the RSS fee code. Simple! (Yahoo! Answers Advanced Search)

The RSS Query 

How to Tap into the Yahoo Answers Database using RSS

The basic query is very easy to construct, and results in an XML feed (RSS) of the current state of the Yahoo Answers database. It can be queried in a number of ways, and the basic form is as follows:

http://answers.yahoo.com/rss/searchq?p=squidoo

The italicized part never changes, and in the above example we have only included one option : the query search term.

This will return an XML feed, but there are many more parameters that we can add to change the way that Yahoo! Answers searches its database.

The complete list of possible options is:

  • p : look for the following words
  • pn : look for items without these words
  • ps : how to use the query words
  • tab : the status of the Answers to check
  • scope : the type of Answers to query for
  • mc : the category to look in
  • asktime : the timescale to look for
Each of these can be used to modify the query, as explained in the following sections of the Lens.

Get XML/RSS Answers 

Just Enough Web Programming with XHTML, PHP, and MySQL

Amazon Price: $15.63 (as of 11/27/2009)Buy Now

For an insight into web development with XML, RSS, AJAX and related technologies this book delivers just enough for you to get started, but not enough to overwhelm you with detail.

The ps and pn Options 

How to exclude words and select how the included words are searched for.

The pn option can be used to exclude words from the query. So, to ask Answers to return details of 'squidoo' but not 'squid', we could use the following options:

  • p=squidoo&pn=squid
If there are multiple words in the inclusive query then we can also set the ps option to a value that corresponds to the kind of search we would like Yahoo Answers to do. These values are:
  • ps=1 : All Words
  • ps=2 : Any Words
  • ps=3 : Exact Phrase
So, to look for the exact phrase 'giant squid', the query options would be:
  • p=giant+squid&ps=3
Of course, the URL from the introduction (the bit in italics) must be added to the front in order for the query to work.

So, the complete URL is:

http://answers.yahoo.com/rss/searchq?p=giant+squid&ps=3

You will note that these are just simple URLs (web addresses) like any others. They can be cut and pasted into a browsers address bar, and will return a piece of well-formed (XML) information that can be viewed with most modern browsers.

The tab and scope Options 

Choosing what areas of Answers are searched, as well as what kinds of Question.

Let's assume that you want to look for only those questions that have been Answered satisfactorily. One reason for doing this might be as a part of an eBook research project.

Often, some of the best ideas come from other people's problems. But, we only want to see those that are actually resolved : so that we have both parts of the equation.

To do this, we use the tab option:
  • tab=0 : All items
  • tab=1 : Resolved items
  • tab=2 : Undecided items
  • tab=3 : Open items
If we are researching questions relating to keyword research, for example, in preparing an eBook, we could retrieve a feed with the following query:

http://answers.yahoo.com/rss/searchq?p=keyword+research&ps=3&tab=1


Note that in the above query, we have also limited the search to the exact phrase using the ps option.

Let's assume that the above yields a long list of questions and answers, so we decide that, actually, we only want to search the Best Answers for the keywords.

This will enable us, we assume, to ensure good quality whilst also receiving Answers that ask questions not explicitly> about keyword research, but which contain the phrase.

To do this, we use the scope option:
  • scope= : All parts
  • scope=subject : The Question
  • scope=bestanswer : The Best Answers only
So, to retrieve only the best answers containing the exact phrase 'keyword research' for resolved questions, the following URL would be used:

http://answers.yahoo.com/rss/searchq?p=keyword+research&ps=3&tab=1&scope=bestanswer

These can be used in any combination, and can be present, but blank (i.e. scope=), or absent.

The mc and asktime Options 

Narrowing the category and choosing a timeframe.

The mc option allows for the selection of a specific category. There are so many of these that it is best to actually use the Answers advanced search function to build a default query on a category, and copy and paste the mc value from the resulting URL.

The asktime is a little simpler to use, and allows a query to specify the timeframe within which the items should fall. The possible values are:

  • asktime= : Any
  • asktime=0 : Less than 7 days old
  • asktime=1 : 7 to 30 days old
  • asktime=2 : 30 to 60 days old
  • asktime=3 : 60 to 90 days old
  • asktime=4 : Over 90 days old.
Remember that these are exact ranges, so if you chose asktime=4 you will not see any items that are 'younger' than 90 days.

All Your Yahoo! Answers Questions Answered... By Yahoo! Answers! 

Loading Fetching RSS feed... please stand by

New Guestbook 

submit

by LeckyT

Web 2.0 RSS and Mashup development is my latest hot topic.

Expect to be reading about my new book soon. Meanwhile, let's carve up those APIs!

(more)

Explore related pages

Create a Lens!