Get Started
First, we'll install the package. Then, we'll make our first authentication to the PlayStation Network. After these steps are completed, you are able to use any function provided by the library.
Quick Start
Install the package:
- npm
- Yarn
npm install psn-api
yarn add psn-api
You will need to be authorized to use the PSN API. To authenticate manually, follow these steps:
In your web browser, visit the PlayStation homepage, click the "Sign In" button, and log in with a PSN account.
In the same browser (due to a persisted cookie), visit this page. You will see a JSON response that looks something like:
{ "npsso": "<64 character token>" }
If you see an error response, try using a different browser.
- You can now obtain an authentication token using your NPSSO with the following function calls from this package.
// This is the value you copied from the previous step.
const myNpsso = "<64 character token>";
// We'll exchange your NPSSO for a special access code.
const accessCode = await exchangeNpssoForCode(npsso);
// ๐ We can use the access code to get your access token and refresh token.
const authorization = await exchangeCodeForAccessToken(accessCode);
- You now have all you need to use any function in the API. Each function takes this authorization object as its first argument. To be more precise, the functions are looking for your
accessToken
value. Here's an example:
// This returns a list of all the games you've earned trophies for.
const trophyTitlesResponse = await getUserTitles(
{ accessToken: authorization.accessToken },
"me"
);