node-trakt

A wrapper for the trakt.tv API

npm install node-trakt
8 downloads in the last week
40 downloads in the last month

node-trakt

node-trakt is a wrapper for the trakt.tv API. It supports:

Install

npm install node-trakt

Example

var trakt = require("node-trakt")("api-key");

// Get movie information for The Lone Ranger (2013)
trakt.movieSummary({ title: "tt1210819" }, function(err, movie){
    console.log(movie);
});

Methods

apiMethod([params,] callback(err, data))

  • params (Optional) An object containing the parameters for the API call. Arrays will be converted/joined to strings if the method is a GET method for convenience.
  • callback Called after the request completed. If an error ocurred err will contain the Error object, otherwise it will be null. The parsed JSON data is returned in data.

API methods are generated by joining the parts of the path, uppercasing every part. (e.g. movie/summary becomes movieSummary)
If a required parameter is omitted, no request is made to the server and instead an error is returned.
This function will pass an auth header for every request if user credentials are provided.

Check out the trakt.tv API docs for documentation on all methods and their parameters.

login(username, password, callback(loggedIn))

  • username
  • password Can be either the password in plain text or the SHA1 encoded password.
  • callback Will be called after testing the credentials with loggedIn being the succes value of the login.

Sets the username and password in an options object so they can later be used in API requests. Tests if the credentials are valid using API method account/test.

isLoggedIn([confirmed])

  • confirmed (Default = true) Whether the login credentials should be confirmed for this function to regard the user logged in. If this is set to false, the function will return true if credentials were provided using login().
  • returns True if the user is logged in, false if not.

Use this to check if the user is logged in.

npm loves you