dribbble-api

Node.js wrapper for the Dribbble API

Dribbble Api 0.0.1

What's this?

This is a node module, serving as Dribbble API wrapper. See the Dribbble API docs for more details.

Dependencies

Currently the only real dependency is Request.

Installation

The easiest way to install is via npm

npm install dribbble-api

Otherwise, you can install this is by taking the code and sticking it in your node_modules folder.

Usage

Dribbble doesn't (yet) require any sort of auth key or access token. Still, this module is a constructor. This way, if things change and keys are required, the constructor would be utilized and legacy code would be less effected.

Making a request looks something like this:

var dribbbleApi = require('dribbble-api')
 
var dribbble = new dribbbleApi()
 
dribbble.list('debuts', function(errresjsonpaging) { })

Every callback gets four arguments; An error (if there is one), the HTTP response, a JSON object (probably what you will want) and a paging object (more on this in the paging section).

All of the player-related functions require a player id (or username).

dribbble.player('44656', function(errresjsonpaging) {
    console.log(json)
})
dribbble.playerShots('44656', function(errresjsonpaging) {
    console.log(json)   // json.shots 
})
dribbble.playerFollowingShots('44656', function(errresjsonpaging) {
    console.log(json)   // json.shots 
})
dribbble.playerLikes('44656', function(errresjsonpaging) {
    console.log(json)   // json.shots 
})
dribbble.playerFollowers('44656', function(errresjsonpaging) {
    console.log(json)   // json.players 
})
dribbble.playerFollows('44656', function(errresjsonpaging) {
    console.log(json)   // json.players 
})
dribbble.playerDraftees('44656', function(errresjsonpaging) {
    console.log(json)   // json.players 
})

All of the shot-related functions, except for list, require a shot id.

dribbble.shot('300230', function(errresjsonpaging) {
    console.log(json)
})
dribbble.shotRebounds('43424', function(errresjsonpaging) {
    console.log(json)   // json.shots 
})
dribbble.shotComments('43424', function(errresjsonpaging) {
    console.log(json)   // json.comments 
})

This one is a bit different. It doesn't take a shot id. Instead it takes the name of a list.

Possible names are popular, debuts and everyone.

If you don't pass a list name it will default to popular.

dribbble.list('popular', function(errresjsonpaging) {
    console.log(json)   // json.shots 
})
 
// has the same effect as 
 
dribbble.list(function(errresjsonpaging) {
    console.log(json)   // json.shots 
})

Options

Dribbble allows for options to be set. You can set these by passing your options, as an {} object, just before the callback.

dribbble.lists('debuts', { per_page: 30, page: 5 }, function(errresjsonpaging) { })

Paging

The paging object returned to the callbacks may contain a next or previous function. These functions allow you to make another request, using the same arguments passed before, but with a new callback.

Here's an example where we request as many pages as we can, from the 'popular list', and add all resulting shots to the popularShots array. Once this is done we'll call onRequestsFinished.

var popularShots = []
 
var onRequestsFinished = function() {
    // do something 
}
 
var requestCallback = function(errresjsonpaging) {
    if (Array.isArray(json.shots)) {
        popularShots = popularShots.concat(json.shots)
    }
 
    if (paging.next) {
        paging.next(requestCallback)
    }
    else {
        onRequestsFinished()
    }
}
 
dribbble.list('popular', requestCallback)

Future Plans