Skip to main content

Python API Wrapper for PlayStation Network API

Project description

PlayStation Network API Wrapper Python (PSNAWP)

Retrieve User Information, Trophies, Game and Store data from the PlayStation Network

PyPI version Downloads python-logo pytest pre-commit Code style: black Documentation Status License: MIT

Coverage

Coverage Report
FileStmtsMissCoverMissing
/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/psnawp_api
   init.py10100% 
   psnawp.py330100% 
/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/psnawp_api/core
   init.py00100% 
   authenticator.py4633 93%
   psnawp_exceptions.py90100% 
/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/psnawp_api/models
   init.py00100% 
   client.py470100% 
   group.py480100% 
   search.py150100% 
   user.py560100% 
/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/psnawp_api/utils
   init.py00100% 
   endpoints.py20100% 
   misc.py130100% 
   request_builder.py711515 79%
TOTAL3411895% 

How to install

From PyPI

pip install PSNAWP

Using setup.py

To install the library into python. First you need to clone the repo at your local machine and run the following command from the root directory of the repo

python setup.py install

Important Links

PyPI: https://pypi.org/project/PSNAWP/

Read the Docs: https://psnawp.readthedocs.io/en/latest/

Getting Started

To get started you need to obtain npsso <64 character code>. You need to follow the following steps

  1. Login into your My PlayStation account.
  2. In another tab, go to https://ca.account.sony.com/api/v1/ssocookie
  3. If you are logged in you should see a text similar to this
{"npsso":"<64 character npsso code>"}

This npsso code will be used in the api for authentication purposes. The refresh token that is generated from npsso lasts about 2 months. After that you have to get a new npsso token. The bot will print a warning if there are less than 3 days left in refresh token expiration.

Following is the quick example on how to use this library

from psnawp_api import PSNAWP

psnawp = PSNAWP('<64 character npsso code>')

# This is you
client = psnawp.me()
print(client.online_id)
print(client.account_id)
print(client.get_account_devices())
print(client.get_profile_legacy())
print(client.friends_list())
print(client.blocked_list())
print(client.available_to_play())
groups = client.get_groups()
print(groups)

# Getting user from online
example_user_1 = psnawp.user(online_id="VaultTec-Co")
example_user_2 = psnawp.user(online_id="test")
print(example_user_1.online_id)
print(example_user_1.account_id)
print(example_user_1.profile())
print(example_user_1.prev_online_id)
print(example_user_1.get_presence())
print(example_user_1.friendship())
print(example_user_1.is_blocked())

# Getting user from Account ID
user_account_id = psnawp.user(account_id='9122947611907501295')
print(user_account_id.online_id)

# Sending Message
group = psnawp.group(group_id='38335156987791a6750a33ae452ec8666177b65e-103')
print(group.get_group_information())
print(group.get_conversation(10))
print(group.send_message("Hello World"))
print(group.change_name("API Testing 3"))
print(group.leave_group())

# Creating new group
new_group = psnawp.group(users_list=[example_user_1, example_user_2])

search = psnawp.search()
print(search.get_title_details(title_id="PPSA03420_00"))
print(search.universal_search("GTA 5"))

Note: If you want to create multiple instances of psnawp you need to get npsso code from separate PSN accounts. If you generate a new npsso with same account your previous npsso will expire immediately.

Contribution

All bug reposts and features requests are welcomed, although I am new at making python libraries, so it may take me a while to implement some features. Suggestions are welcomes if I am doing something that is an unconventional way of doing it.

Disclaimer

This project was not intended to be used for spam, abuse, or anything of the sort. Any use of this project for those purposes is not endorsed. Please keep this in mind when creating applications using this API wrapper.

Credit

This project contains code from PlayStationNetwork::API and PSN-PHP Wrapper that was translated to Python. See more in LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PSNAWP-1.0.3.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PSNAWP-1.0.3-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file PSNAWP-1.0.3.tar.gz.

File metadata

  • Download URL: PSNAWP-1.0.3.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for PSNAWP-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7bf9cac7ae7536d8d44bd04901e396dd4e11a0c1644aac6e16b8dab04818a3c3
MD5 565bb13b87803686202cae20e141e0a1
BLAKE2b-256 1982a3bbc4f70e6d5d22840693ac1bb7b9cc8907a1160acbdd7c63ae000a10a1

See more details on using hashes here.

File details

Details for the file PSNAWP-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: PSNAWP-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for PSNAWP-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cdf09369a51dce5742b95bdef8e01540e7e7a825c312ae7d0265c510404e257
MD5 0f9b92a1e76526ff9039d001d3a0ba31
BLAKE2b-256 909a4080b6ac4c16d67eab4cce42460303adec5ea506914fd32c204021db3664

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page