Yahoo! APIs
Yahoo! APIs
Yahoo! have recently been populating their developer page with an impressive array of APIs for folks to access the raw data from their various services, as well as their recent acquisitions. The services are super easy to use too.
When Google first announced their SOAP API to their search engine, while the data was there to be had, there was a large barrier to getting to it. Yahoo's APIs can all be accessed using REST, which means simple GET and POST requests and as well as offering language neutral XML they also offer JSON and PHP formatted results. For a Web developer constrained to a Web browser it doesn't get better than this, the APIs can be queried accross domains.
Below is a simple object that I've been using to fire off requests to the Yahoo APIs.
var yApi = { IMAGE: "http://api.search.yahoo.com/ImageSearchService/V1/imageSearch", RELATED: "http://api.search.yahoo.com/WebSearchService/V1/relatedSuggestion", MYWEB_URL: "http://api.search.yahoo.com/MyWebService/V1/urlSearch", MYWEB_TAG: "http://api.search.yahoo.com/MyWebService/V1/tagSearch", defaults: { appid: "idontsmoke" }, get: function (url, parameters) { // add in the defaults for (var key in this.defaults) { if (parameters[key] == undefined) { parameters[key] = this.defaults[key]; } } url = this.encode_url(url, parameters); var script = document.createElement("script"); script.src = url; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); }, encode_url: function (url, parameters) { components = []; for (var key in parameters) { values = parameters[key]; if (typeof parameters[key] != "array") { values = [values]; } for (var i = 0, len = values.length; i < len; i++) { components.push( encodeURIComponent(key) + "=" + encodeURIComponent(values[i])); } } return url + "?" + components.join("&"); } }
Which can then be called using something like:
yApi.get(yApi.MYWEB_TAG, { yahooid: "ashleysowden", tag: ["javascript", "awesome"], output: "json", callback: "showUrls" });
The only problem is I can't get the damn thing to respond with a list constrained to my Yahoo ID and the support channels for the APIs seem questionable at best.

0 Comments:
Post a Comment
<< Home