Retrieve User Information, Trophies, Game and Store data from the PlayStation Network
Coverage Report
File | Stmts | Miss | Cover | Missing |
---|---|---|---|---|
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/psnawp_api | ||||
init.py | 1 | 0 | 100% | |
psnawp.py | 30 | 12 | 12 | 60% |
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/psnawp_api/core | ||||
init.py | 0 | 0 | 100% | |
authenticator.py | 46 | 18 | 18 | 61% |
psnawp_exceptions.py | 9 | 0 | 100% | |
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/psnawp_api/models | ||||
init.py | 0 | 0 | 100% | |
client.py | 47 | 27 | 27 | 43% |
group.py | 52 | 35 | 35 | 33% |
search.py | 15 | 7 | 7 | 53% |
user.py | 72 | 53 | 53 | 26% |
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/psnawp_api/utils | ||||
init.py | 0 | 0 | 100% | |
endpoints.py | 2 | 0 | 100% | |
misc.py | 13 | 9 | 9 | 31% |
request_builder.py | 71 | 59 | 59 | 17% |
TOTAL | 358 | 220 | 39% |
pip install PSNAWP
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
PyPI: https://pypi.org/project/PSNAWP/
Read the Docs: https://psnawp.readthedocs.io/en/latest/
To get started you need to obtain npsso <64 character code>. You need to follow the following steps
- Login into your My PlayStation account.
- In another tab, go to https://ca.account.sony.com/api/v1/ssocookie
- 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.
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.
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.
This project contains code from PlayStationNetwork::API and PSN-PHP Wrapper that was translated to Python. See more in LICENSE