damn

DeviantArt API client

dAmn

Node.js DeviantArt API client

var dAmn = require('damn');
 
dAmn.public(1234, 'cl13nt_s3cr3t', function(errdaClient) {
// Fetch today's daily deviations 
da.getDailyDeviations(function(errdata) {
// Output one title 
console.log(data[0].title);
});
});
 

dAmn currently supports two authentication methods : Client Credentials and Implicit. Both of them provide access to public endpoints. The Implicit method however is an user authentication method and also provides access to user-specific APIs.

Both methods require a client_id and a client_secret to be granted an access token. These are obtained by creating an app in DeviantArt's application page.

The easiest way to access public API is to use the Client Credentials method, which is available via dAmn.public :

dAmn.public(4321, 'cl13nt_s3cr3t', function(errpublicClient) {
publicClient.getDeviation(...);
});

Where 4321 is your client_id and cl13nt_s3cr3t is your client_secret.

This returns a Client object from which you can call the methods marked public described below.

Accessing user-specific endpoints can only be done via using the Implicit authentication method. This methods requires you to provide an username, a password, a client_id and redirect_uri for the application you created.

If you're using this method, make sure your "OAuth2 Grant Type" settings is set to "Implicit" in your application parameters :

To instanciate a "private" client you may use dAmn.private method :

dAmn.private('username', 'password', 1234, 'https://www.example.com', function(errprivateClient) {
privateClient.getWatchFeed(...);
});

Where 1234 is your client_id and https://www.example.com is your redirect_uri.

This returns a Client object from which you can call all the methods described below.

All these methods are asynchronous.

Public endpoint

Returns the list of today's daily deviations :

client.getDailyDeviations(function(errdailyDeviations) {
console.log(dailyDeviations);
});

Parameters :

  • callback : called with two parameters : error (null if none) and an array containing the daily deviations.

Private endpoint

Returns the list of current user notifications :

client.getNotifications(function(errnotifications) {
   console.log(notifications);
});

Parameters :

  • callback : called with two parameters : error (null if none) and an array containing the notifications.

Private endpoint

Returns the current user's watch feed :

client.getWatchFeed(function(errwatchFeedItems) {
   console.log(watchFeedItems);
});

Parameters :

  • callback : called with two parameters : error (null if none) and an array containing the watch feed items.

Public endpoint

Implementation of DA's placebo route. Use it to check you access token validity. Or better yet, use checkAccessToken() !

client.placebo(function(errstatusData) {
   console.log(statusData);
});

Parameters :

  • callback : called with two parameters : error (null if none) and an the status object.

Check the validity of your access token.

client.checkAccessToken(function(errisValid) {
   console.log(isValid);
});

Parameters :

  • callback : called with two parameters : error (null if none) and a boolean indicating whether the current access token is still valid.
  • [X] Use Node.js v4.0.0 and ES6 features
  • [ ] Automate token refresh
  • [ ] Use code linting tools :
    • [ ] jshint
    • [ ] jscs
  • [ ] Add access to the following routes :
    • [ ] /deviation/{deviationid} Fetch a deviation
    • [ ] /deviation/content Fetch full data that is not included in the main devaition object
    • [ ] /browse/morelikethis Fetch MoreLikeThis result for a seed deviation
    • [ ] /browse/newest Browse newest deviations
    • [ ] /browse/popular Browse popular deviations
    • [ ] /browse/hot Browse whats hot deviations
    • [ ] and all others routes ?
  • [ ] Revoke access / logout
  • [ ] Find a way to implement Authorization Code as an authentication method