Sunday, March 14, 2010

NYTimes Json Feeds

Just getting started at this, but I'm planning on working now with the New York Times JSON API that is provided.

Looks like this is a very solid api, that allows for feeds from entertainment, to current Congress members, to much, much more...

Just signed up for my membership and requested an API by going to: NY Times Registration

A quick example that I just used for testing...

$.getJSON(
"http://api.nytimes.com/svc/news/v2/all/recent.json?api-key=XXX",
function(data) {
$.each(data.results,
function(index, item) {
var myItem = $("<ul></ul>");
$("<li></li>").html(item.headline).appendTo(myItem)
.wrap("<a target='_blank' href='" + item.url + "')></a>");
myItem.appendTo("#results");
});
});
});

Send that to a div called 'results', and you're done.

0 comments: