Socket
Socket
Sign inDemoInstall

psn-api

Package Overview
Dependencies
9
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    psn-api

A well-tested library that lets you get trophy, user, and game data from the PlayStation Network.


Version published
Weekly downloads
121
decreased by-38.89%
Maintainers
1
Install size
0.983 MB
Created
Weekly downloads
 

Readme

Source

psn-api



A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.

Documentation: Get Started

Styled with Prettier Semantic Release


Features

✅  Modular by design, and supports tree-shaking.
✅  Aligns with the community API documentation.
✅  Supports Node environments (14 and above).
✅  Supports browsers.
✅  Ships with TypeScript support and types.
✅  Tiny, <3Kb.


Documentation

Learn how to authenticate and start pulling data from the PlayStation Network on our documentation website.

Installation

Run the following command:

npm install psn-api

How to obtain an authentication token

To use any endpoint function in the API, you must first be authorized by PSN. Fortunately, this is a fairly straightforward process.

  1. In your web browser, visit https://www.playstation.com/, click the "Sign In" button, and log in with a PSN account.

  2. In the same browser (due to a persisted cookie), visit https://ca.account.sony.com/api/v1/ssocookie. You will see a JSON response that looks something like:

{ "npsso": "<64 character token>" }

Copy your NPSSO. Do not expose it anywhere publicly, it is equivalent to your password.

If you see an error response, try using different browser.

  1. 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);
  1. You should now be all set to use any endpoint provided by this package. Each function requires as its first argument an object containing your access token. ex:
const authorization = await exchangeCodeForAccessToken(accessCode);

// This returns a list of all the games you've earned trophies for.
const trophyTitlesResponse = await getUserTitles(
  { accessToken: authorization.accessToken },
  "me"
);

API

Click the function names to open their complete docs on the docs site.

Authentication

  • makeUniversalSearch() - Search the PSN API. This is a good way to find a user's accountId from their username.

Users

Trophies

Examples

Prior Art

Disclaimer

This project is not intended to be used for spam or abuse. Please use this project to elevate the PlayStation Network experience, not damage it.

Contributors


Wes Copeland

💻 💡 📖

xelnia

🤔 📓

andshrew

📖

Susan Ma

📖

Travis Roy

💻 💡 📖

Keywords

FAQs

Last updated on 19 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc