Christian Heilmann

⚡️Yahoo BOSS keyword extraction API wrappers (JS/PHP)

Thursday, November 13th, 2008 at 3:49 pm

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: , , ,

Share on Twitter