Yahoo BOSS keyword extraction API wrappers (JS/PHP)

One of my favourite “old school” Yahoo APIs is the term extractor which is a service that extracts relevant keywords from a text you give it.

Yahoo BOSS is now supporting this feature for indexed web sites. While you’d normally just get a list of sites with for example:

http://boss.yahooapis.com/ysearch/web/v1/donkeys?format=xml&appid={appid}

You can get the keywords for each of the pages returned by adding the (so far undocumented) view=keyterms parameter:

http://boss.yahooapis.com/ysearch/web/v1/donkeys?format=xml&view=keyterms&appid={appid}

This can be pretty useful to get a list of keywords related to a certain term.

In order to do this, I’ve written a small API in PHP and JavaScript that gets you the related terms from the first ten search results and returns them as an array.

The PHP API wrapper

The PHP version takes three parameters: the mandatory term to search for, an optional callback method name to wrap around the JSON return value and an optional format parameter that can be set to HTML to return an HTML list instead of a JSON object.

The JavaScript API wrapper

The JavaScript wrapper uses dynamically generated script nodes to retrieve the data and can be used by simply calling a BOSSTERMS.get() method with a search term and the name of a callback method. The return object has a term property, the keywords as an array and a string that is an HTML list of the terms.

Get the lot

You can download the whole BOSS keyword API here. As always, it is BSD licensed, so go nuts using it :)

Tags: , , ,

3 Responses to “Yahoo BOSS keyword extraction API wrappers (JS/PHP)”

  1. Russel Says:

    I have been using the Yahoo API for about a year and a half now. There is one limitation, and if you have a large dynamic site like I do, its a problem. Yahoo limits each IP to 5,000 queries a day. For most sites this isn’t issue – but is for me. So I have been on the hunt for other similar API’s and thus far haven’t found any.

    Do you know if Yahoo offers a paid for service to go beyond the limit, or for that matter, know of any other API’s similar to Yahoo’s service.

    It really seems to be a one of a kind service and from all my research no one else seems to offer anything like it.

    Thanks.

    PS: I use Perl’s module WWW::Yahoo::KeywordExtractor – virtually no documentation and extremely poor error handling (would break the script/page if Yahoo wasn’t working or the limit was reached) which I had to add in myself.

  2. Alex Says:

    To the commenter above (Russel): Check out AlchemyAPI for a commercial alternative to the Yahoo API.

    It supports more languages (8) than BOSS, offers commercial SLAs, can do millions of queries a day, etc.

  3. jason Says:

    Hi, Chris,

    The PHP samples seem to be loading empty arrays. The raw XML you demo above is still working. Any ideas?

    jason

Leave a Reply

Wait till I come! is the blog of Christian Heilmann , a developer evangelist living and working in London, England. Download vcard.

Feed me, Seymour: Entries (RSS) and Comments (RSS).