0.0.2 • Published 12 years ago
node-trakt v0.0.2
node-trakt
node-trakt is a wrapper for the trakt.tv API. It supports:
- All GET and POST methods defined on the trakt.tv API docs
- User authorization/login
Install
npm install node-traktExample
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.callbackCalled after the request completed. If an error ocurrederrwill contain the Error object, otherwise it will be null. The parsed JSON data is returned indata.
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))
usernamepasswordCan be either the password in plain text or the SHA1 encoded password.callbackWill be called after testing the credentials withloggedInbeing 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 usinglogin().returnsTrue if the user is logged in, false if not.
Use this to check if the user is logged in.