API Framework for PSN
This is a simple Node.JS API for accessing PSN data.
This is heavily based on work by psnapi.org and gumer-psn.
Note: v0.1.x is a completely new API that is incompatible with 0.0.x. Please take care when writing your dependancies.
You can install it with the package manager
npm install PSNjs
Or clone the repository and install the dependencies
git clone https://github.com/cubehouse/PSNjs.git cd PSNjs/ npm install
var PSNjs = require'PSNjs';var psn =// PSN email and passwordemail: "PSNEMAIL"password: "PSNPASSWORD"// debug printingdebug: true// optionally store session tokens in a file to speed up future connectionauthfile: ".psnAuth";// get the above user's trophiespsngetUserTrophies// check for an errorif errorconsole.log"Error fetching trophies: " + error;return;// success! print out trophy dataconsole.logJSONstringifydata null 2;;
email: "PSNEMAIL" // your emailpassword: "PSNPASSWORD" // your passworddebug: true // enable debug logging?requestDebug: false // enable the request library's debug output?autoconnect: false // make a PSN request immediately (make sure you use onReady if you do this)authfile: ".psnAuth" // optionally store PSN session tokens in this file// this function will be called when the API is ready (mainly used when autoconnect is true)
If you don't want to use the authfile option, you can manually write save/load functions. For example, using Redis or something instead of the filesystem.
var psn =// PSN email and passwordemail: "PSNEMAIL"password: "PSNPASSWORD";// load example (data should be a Base64 string)psnLoad"SAVED DATA"if errorconsole.log"Error loading data: " + error;return;// load successful!;// save examplepsnOnSave// save data// data will be a Base64 stringmySaveSystemsavedata// all done!// always call the callback so the API knows you're done saving!// handle your own error reporting and debuggingcallback;;;
Get a PSN user's profile
Get current user's message groups
Get data from a specific message. All this data can be found in getMessageGroups
Get the signed-in user's activity feed
Like an activity from the activity feed
Dislike an activity from the activity feed
Get notifications of currently authenticated user
Add a friend to PSN (must have received a friend request from the user)
Remove a friend from PSN
Send a friend request to a user
Get the user's friend list
Generate a friend URL you can give to people to add you as a friend.
Fetch trophy data for the logged in user (and optionally compare to another user)
Get list of trophy groups for a title (eg. base game + DLC packs)
Get a title's trophies (supplying a trophy group), optionally comparing to another user.
Get data on a specific trophy in a title with supplied trophyId. Optionally compare to a username.