Digg API Javascript Toolkit

Note: This is currently going under testing. Please let me know if you run into any issues.

The Digg Javascript API Toolkit is a simple javascript file that can be used to create client side web pages that interact with Digg. That is, there is no requirement for any server side code.

The idea behind this toolkit is to make it as simple as possible for the developer to use the digg API while keeping overhead low.

To use it, just include the file in your html and you can call any of the functions below under the digg ‘namespace’ AFTER you initialize with your appkey.
ie:
digg.initialize(”http://www.neaveru.com”);
digg.getUserFriends(…);

The following are standard parameters to each of the toolkit functions:
cb: A function that will be called when non-error data is received. Mandatory
errorCb: A function that will be called when error data is received. Optional
params: An object that will pass an query string parameters to the api. Common ones are sort, offset and count. Optional
extra: Any extra information you want to pass to the function. Can be anything you want it to be. Optional

Example 1:
Sample usage of getUserFriends, which has the following definition:
getUserFriends(cb, errorCb, userName, params, extra);

Code (javascript)

function parseFriend(data, userName, extra)
{
  alert(userName + "has " + data.total + " friends");
}
digg.initialize("http://www.neaveru.com");
//No error handling, default params, no extra
digg.getUserFriends(parseFriends, null, "neaveru");
 

More extensive examples:
Get list of errors. Very basic sample
Dynamically get friends. This is more advanced and shows some of the power of the toolkit.


getErrors(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getError(cb, errorCb, code, params, extra);
function cb(data, code, extra) {…};
function errorCb(data, code, extra) {…};
getStories(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStories(cb, errorCb, arrayOfStoryIds, params, extra);
function cb(data, arrayOfStoryIds, extra) {…};
function errorCb(data, arrayOfStoryIds, extra) {…};
getStoriesComments(cb, errorCb, arrayOfStoryIds, params, extra);
function cb(data, arrayOfStoryIds, extra) {…};
function errorCb(data, arrayOfStoryIds, extra) {…};
getStoriesDiggs(cb, errorCb, arrayOfStoryIds, params, extra);
function cb(data, arrayOfStoryIds, extra) {…};
function errorCb(data, arrayOfStoryIds, extra) {…};
getStoriesComments(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesContainer(cb, errorCb, containerName, params, extra);
function cb(data, containerName, extra) {…};
function errorCb(data, containerName, extra) {…};
getStoriesContainerPopular(cb, errorCb, containerName, params, extra);
function cb(data, containerName, extra) {…};
function errorCb(data, containerName, extra) {…};
getStoriesContainerUpcoming(cb, errorCb, containerName, params, extra);
function cb(data, containerName, extra) {…};
function errorCb(data, containerName, extra) {…};
getStoriesDiggs(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesPopular(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesPopularComments(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesPopularDiggs(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesTopic(cb, errorCb, topicName, params, extra);
function cb(data, topicName, extra) {…};
function errorCb(data, topicName, extra) {…};
getStoriesTopicPopular(cb, errorCb, topicName, params, extra);
function cb(data, topicName, extra) {…};
function errorCb(data, topicName, extra) {…};
getStoriesTopicUpcoming(cb, errorCb, topicName, params, extra);
function cb(data, topicName, extra) {…};
function errorCb(data, topicName, extra) {…};
getStoriesUpcoming(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesUpcomingComments(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStoriesUpcomingDiggs(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getStory(cb, errorCb, storyId, params, extra);
function cb(data, storyId, extra) {…};
function errorCb(data, storyId, extra) {…};
getStoryComments(cb, errorCb, storyId, params, extra);
function cb(data, storyId, extra) {…};
function errorCb(data, storyId, extra) {…};
getStoryDiggs(cb, errorCb, storyId, params, extra);
function cb(data, storyId, extra) {…};
function errorCb(data, storyId, extra) {…};
getStoryComment(cb, errorCb, storyId, commentId, params, extra);
function cb(data, storyId, commentId, extra) {…};
function errorCb(data, storyId, commentId, extra) {…};
getStoryCommentReplies(cb, errorCb, storyId, commentId, params, extra);
function cb(data, storyId, commentId, extra) {…};
function errorCb(data, storyId, commentId, extra) {…};
getStoryComments(cb, errorCb, storyId, params, extra);
function cb(data, storyId, extra) {…};
function errorCb(data, storyId, extra) {…};
getStoryUserDigg(cb, errorCb, storyId, userName, params, extra);
function cb(data, storyId, userName, extra) {…};
function errorCb(data, storyId, userName, extra) {…};
getTopics(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getUser(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUserComments(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUserDiggs(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUserFan(cb, errorCb, userName, fanUserName, params, extra);
function cb(data, userName, fanUserName, extra) {…};
function errorCb(data, userName, fanUserName, extra) {…};
getUserFans(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUserFriend(cb, errorCb, userName, friendUserName, params, extra);
function cb(data, userName, friendUserName, extra) {…};
function errorCb(data, userName, friendUserName, extra) {…};
getUserFriends(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUserSubmissions(cb, errorCb, userName, params, extra);
function cb(data, userName, extra) {…};
function errorCb(data, userName, extra) {…};
getUsers(cb, errorCb, params, extra);
function cb(data, extra) {…};
function errorCb(data, extra) {…};
getUsersComments(cb, errorCb, arrayOfUserNames, params, extra);
function cb(data, arrayOfUserNames, extra) {…};
function errorCb(data, arrayOfUserNames, extra) {…};
getUsersDiggs(cb, errorCb, arrayOfUserNames, params, extra);
function cb(data, arrayOfUserNames, extra) {…};
function errorCb(data, arrayOfUserNames, extra) {…};