Monday, July 23, 2007

Top 10 Diggs Over Past 12 Hours

The first step towards grabbing the top 10 diggs over the past 12 hours is working with the Digg API. Digg has set up their API to make the information on Digg.com easily available to everyone. If you take a look at the "List Stories" link on the far right, you will see some documentation on how to use the api to grab a list of stories -- which is exactly what we want.
Since we know that we want a list of stories for our end goal, the url that we are going to use for the api is going to start like this:

  • http://services.digg.com/stories
Next, we tag on a /popular to make sure that we are grabbing stories that have popular status. From here we can set a couple arguments to make the data returned a little more specific. These arguments will be count, min_promote_date, and we will also need to set appkey. Heres how it is going to look:
  • count=100
  • min_promote_date=[current time - 12 hours]
  • appkey = [the url making the request, or something similar]
If you are just looking for the url, here is the end result:



http://services.digg.com/stories/popular?count=100&min_promote_
date=1185219546&appkey=http://red-top10.blogspot.com




Here is the explanation: We set count to 100 because we want the most results possible, and Digg sets a limit of 100 on the number of stories returned. In case you are curious, the default for count is 10 if you decide not to specify a number for it. The min_promote_date is required to be in the number of seconds since the unix epoch time format. The time I just put into that link was at
Monday, July 23rd 2007, 8:12:27 (GMT). This is because at the moment I wrote the link, Monday, July 23rd 2007, 8:12:27 (GMT) was exactly 12 hours ago. Last, appkey always needs to be set in order to use the api, and it needs to be set to the url making the request or a few other options. Here is how Digg describes what it needs to be:
  • The application itself, if it's a web application.
  • A web page describing the application.
  • A web page offering the application for download.
  • The author's web site.
From here, we have the data we need in xml format. However, we still have a little work to do. We need to sort the results by number of diggs, and then output the stories in a neat little format. Check back tomorrow for that stage of the digg top 10 list.

No comments: