Posted on 28 April 2012

I am happy to announce the availability of as3dribbble, an ActionScript client
library for working with Dribbble.com APIs. The
library is strongly-typed, pagination-aware, and rate-limit aware for accessing all
the current APIs. The library also exposes a convenience class called DribbbleInvoker
that may be used to add more APIs (should they get added in future and this library
looses track). The invoker is rate-limit safe.

Usage

A simple example to use is as under,

privatefunctiongetShotDetails():void{varclient:DribbbleClient=newDribbbleClient();// the requestID can then be used to check which request failedvarrequestID:uint=client.getShot(12,showShot,errorHandler);}privatefunctionshowShot(shot:Shot):void{trace('received shot details: '+shot);}privatefunctionerrorHandler(id:uint):void{// error occured when fetching shot details}

Pagination Support

All API methods that support pagination have a corresponding, pagination-aware method
available as well. For example, when fetching comments for a shot you may do,

// or, may provide the number of results to fetch as well // fetch results from page 2, with 15 results per page requestID = getShotComments(1, showComments, errorHandler, 2, 15); }}</pre>The current default for number of results per page is 15 per Dribbble API. Refer
http://dribbble.com/api for more details.
<h3>Rate-Limiting and Exceptions</h3>By default, the
DribbbleClient will throw a
DribbbleApiRateLimitException run-time error when the request rate goes over the board. This makes sure that your client does not need to catch unnecessary exceptions during invocation. In case you wish, you may catch this exception and delay the request to a future time as,
<pre class="brush: as3">private function getShot():void { var shot:Shot = null; var shotID:uint = 1;

try { var requestID:uint = client.getShot(shotID, showShot, errorHandler); } catch(e:DribbbleApiRateLimitException) { // wait for a minute setTimeOut(getShot, 1000 * 60); // call again after a minute }}</pre>If you wish to prevent the code from throwing the
DribbbleApiRateLimitException exception, you can do so when creating the client.
<pre class="brush: as3">var client:DribbbleClient = new DribbbleClient(false);</pre>Any invocations on this client, will not throw the error, but return a
null back as the result to the completion handler you specified.

<h3>Dependencies</h3>The library does not depend on any third-party libraries and is self-contained. The library has been compiled and tested using Adobe Flex 4.6/Adobe AIR 3.0.