Code Monkey home page Code Monkey logo

pxs-psn-api's Introduction

Example:

  • You need access token to interact with PSN APIs. They can be obtained with a npsso code. See HERE for detail how to get them

  • If you want an automated method to obtain npsso codes. See HERE

  • chage your npsso in example.js and run node example.js

// import class
const PSN = require('./index.js');

// psn object accept optional params when construct.
const psn = new PSN({
    lang: "en",  //(default value en)
    region: "hk",  // server region(default value us)
    refresh_token: null, //refresh_token(default value null)
    access_token: null  //access_token(default value null)
});

const npsso = "put your npsso code here in string form";

async function main() {
    try {
        await psn.auth(npsso);

        // access token is used to call other api, and refresh token is used to get new access_token when it's expired
        console.log(psn.access_token, psn.refresh_token);

        // get user profile with access_token
        const profile = await psn.getProfile("Hakoom");
        console.log(profile);

    } catch (e) {
        console.log('error: ', e);
    }
}

main();
// other useful api calls

psn.refreshTokens() // update your tokens

psn.searchGame(name, lang, region, age)   // find a named game from PSN store

psn.sendMessage(threadId, message, file_path)   // send a message to an PSN user(the target user must have a according privacy setting)

psn.getSummary(offset, onlineId) // get trophy summary of a given PSN user

pxs-psn-api's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.