Giter VIP home page Giter VIP logo

psnawp's Introduction

PlayStation Logo PlayStation Network API Wrapper Python (PSNAWP)

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

PyPI version Downloads python-logo Checked with pyright Documentation Status Poetry pre-commit pytest Ruff License: MIT

\n

How to install

From PyPI

pip install PSNAWP

Important Links

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

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

Getting Started

Caution

This library is an unofficial and reverse-engineered API wrapper for the PlayStation Network (PSN). It has been developed based on the reverse engineering of the PSN Android app. The API wrapper (>= v2.1.0) will self rate limit at 300 requests per 15 minutes. However, it is still important that you don't send bulk requests using this API. Excessive use of API may lead to your PSN account being temporarily or permanently banned.

You can also create a dedicated account to use this library so that in the worst-case scenario you do not lose access to your primary account, along with your video games and progress.

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
from psnawp_api.models import SearchDomain
from psnawp_api.models.trophies import PlatformType

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

# Your Personal Account Info
client = psnawp.me()
print(f"Online ID: {client.online_id}")
print(f"Account ID: {client.account_id}")
print(f"Profile: {client.get_profile_legacy()} \n")

# Your Registered Devices
devices = client.get_account_devices()
for device in devices:
    print(f"Device: {device} \n")

# Your Friends List
friends_list = client.friends_list()
for friend in friends_list:
    print(f"Friend: {friend} \n")

# Your Players Blocked List
blocked_list = client.blocked_list()
for blocked_user in blocked_list:
    print(f"Blocked User: {blocked_user} \n")

# Your Friends in "Notify when available" List
available_to_play = client.available_to_play()
for user in available_to_play:
    print(f"Available to Play: {user} \n")

# Your trophies (PS4)
for trophy in client.trophies("NPWR22810_00", PlatformType.PS4):
    print(trophy)

# Your Chat Groups
groups = client.get_groups()
first_group_id = None  # This will be used later to test group methods
for id, group in enumerate(groups):
    if id == 0:  # Get the first group ID
        first_group_id = group.group_id

    group_info = group.get_group_information()
    print(f"Group {id}: {group_info} \n")

# Your Playing time (PS4, PS5 above only)
titles_with_stats = client.title_stats()
for title in titles_with_stats:
    print(
        f" \
        Game: {title.name} - \
        Play Count: {title.play_count} - \
        Play Duration: {title.play_duration} \n"
    )


# Other User's
example_user_1 = psnawp.user(online_id="VaultTec-Co")  # Get a PSN player by their Online ID
print(f"User 1 Online ID: {example_user_1.online_id}")
print(f"User 1 Account ID: {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())

# Example of getting a user by their account ID
user_account_id = psnawp.user(account_id="9122947611907501295")
print(f"User Account ID: {user_account_id.online_id}")


# Messaging and Groups Interaction
group = psnawp.group(group_id=first_group_id)  # This is the first group ID we got earlier - i.e. the first group in your groups list
print(group.get_group_information())
print(group.get_conversation(10))  # Get the last 10 messages in the group
print(group.send_message("Hello World"))
print(group.change_name("API Testing 3"))
# print(group.leave_group()) # Uncomment to leave the group

# Create a new group with other users - i.e. 'VaultTec-Co' and 'test'
example_user_2 = psnawp.user(online_id="test")
new_group = psnawp.group(users_list=[example_user_1, example_user_2])
print(new_group.get_group_information())
# You can use the same above methods to interact with the new group - i.e. send messages, change name, etc.

# Searching for Game Titles
search = psnawp.search(search_query="GTA 5", search_domain=SearchDomain.FULL_GAMES)
for search_result in search:
    print(search_result["result"]["invariantName"])

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. Also, special thanks @andshrew for documenting the PlayStation Trophy endpoints. All licenses are included in this repository.

psnawp's People

Contributors

dev-r avatar github-actions[bot] avatar isfakeaccount avatar kerdion avatar niccologranieri avatar omz1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psnawp's Issues

Feature Request: Better auth / token refresh flow

I know you are likely limited by what sony exposes to you but if it was possible to build in some kind of login / auth flow that would be really helpful. Additionally making it so tokens can be refreshed.

I was looking to use this in a python project of mine and I really can't be manually authing it all the time (even more so because I don't know how long this token lasts).

Love the work on this so far!

Add Endpoint to remove player from Groups endpoint

Discussed in #51

Originally posted by tim140701 August 12, 2023
Hey, apologies if this in the wrong section - I've been really looking into the psn api. I saw all of your hard work and research on it and was wondering if you ever found an endpoint for kicking players from a group. Would be really helpful as wish to make a discord bot to control a psn group that usually stays at 100/100 players and sometimes needs people removed to add others.

Game list ?

Hello,
Is it possible to get the list of the games owned by the user ? (at least myself)
I couldn't find it.

Thank you, regards

Regarding Title Id

Is there any method to find out if the title id is a game using the PSN API?

Add method to Remove friends

Discussed in #8

Originally posted by Kenshin9977 June 9, 2021
What I want is a way to delete multiple friends automatically. I tried using Selenium but to no avail. This API seems to be the way to proceed.
What would be awesome is the possibility to delete a friend through the API as it would allow me to do what I want. Through Selenium I'm limited to 4 deletion before the website ignores my actions. Is it doable ?
With this API I can also get my friends list but only their account ID. To sort them I'd need a way to get their online ID directly or using their account ID. At worst I can manage some other way to retrieve the friends list with their online ID through Selenium.

`get_groups` not working

Hello! I have tried to run get_groups method but it doesn't work:

from psnawp_api import PSNAWP

psnawp = PSNAWP('...')

client = psnawp.me()
groups = client.get_groups()
for group in groups:
    print(group)

Exception traceback:

Traceback (most recent call last):
  File "/home/swimmwatch/Desktop/learn/psn-bot/main.py", line 15, in <module>
    groups = client.get_groups()
             ^^^^^^^^^^^^^^^^^^^
  File "/home/swimmwatch/.cache/pypoetry/virtualenvs/psn-bot-tWdK-Kv6-py3.11/lib/python3.11/site-packages/psnawp_api/models/client.py", line 218, in get_groups
    response = self._request_builder.get(url=f"{BASE_PATH['gaming_lounge']}{API_PATH['my_groups']}", params=param).json()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/swimmwatch/.cache/pypoetry/virtualenvs/psn-bot-tWdK-Kv6-py3.11/lib/python3.11/site-packages/psnawp_api/utils/request_builder.py", line 79, in get
    response_checker(response)
  File "/home/swimmwatch/.cache/pypoetry/virtualenvs/psn-bot-tWdK-Kv6-py3.11/lib/python3.11/site-packages/psnawp_api/utils/request_builder.py", line 31, in response_checker
    raise PSNAWPForbidden(response.text)
psnawp_api.core.psnawp_exceptions.PSNAWPForbidden: {"error":{"referenceId":"fee7ed74-ef3d-11ee-8793-09bda2ebb9bf","code":2286097,"message":"Not permitted by parental control"}}

Can you please tell me what the problem might be?

I have created the new account for testing this Python package. This account doesn't have parental control.

Change in game title limits

I am currently trying to collect PS4 gameplay time data using the title_stats function, but I get the following error

psnawp_api.core.psnawp_exceptions.PSNAWPBadRequest: {"error":{"reason":"BadRequest","code":3239940,"source":"Gamelist","message":"invalid request, requested limit=500 allowed limit=200","referenceId":"21267330-64b4-1031-a77b-29ec659a0e14"}}

From the message I am thinking that this is due to the game title limit being exceeded, is it possible to change this limit?

Can't find user via account_id

Hi there

Great API and I'm using it to get alerds when some of my friends go online.

After the recent changes, I'm not able to loop through my client.get_friends() over psnawp.user to get the user details.

It seems that the call psnawp.user() with parameter account_id isn't implemented correctly.

I guess the problem is in psnawp.py on line 40

        account_id = None
        if 'account_id' in kwargs.keys():
            online_id = kwargs['account_id']

Line 40 should be account_id = kwargs['account_id'] I guess.

Could you please take a look at this?

Regards
Flavestarr

aboutMe doesn't work

Trying to print aboutMe from any account will come up empty (even if it is not). I thought it was my error, but by checking several times and having "print(idonline.profile())" (where idonline = user input to write a psn id) print directly, the output for "aboutMe" is "'aboutMe': ''," i.e., blank, even though this is not. Only this currently seems not to work, the other keys (avatar, isPlus etc.. ) work perfectly

ReadMe Client

Just testing this out real quick, Client() would currently need request_builder passed to it...

client = client.Client(psnawp.request_builder)

N00b here πŸ–οΈclient.title_stats() Question

client.title_stats() returns a class object, and I've done a dir to check whats in it, but I can't seem to get any title stats from it. I'm looking for 'total number of hrs wasted on Elden Ring' type data, is that what this class can return?

Played Games by a User

I'm getting
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://m.np.playstation.net/api/userProfile/v1/internal/users/6207657462640101457/basicPresences?type=primary

this error on calling get_presence() function for particular account, can anyone help to find out what it mean and how can i solve this?

search question

can you pls tell me, why do I get this error?

{
    "error": {
        "referenceId": "16dd1d74-b0e7-4d56-aafd-017e15d257f5",
        "code": 3415813,
        "message": "JSON parse error: Cannot construct instance of `com.sony.sie.kamaji.search.universal.model.openapi.SearchDomain`, problem: Unexpected value 'ConceptGameMobileApp'; nested exception is com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `com.sony.sie.kamaji.search.universal.model.openapi.SearchDomain`, problem: Unexpected value 'ConceptGameMobileApp'\n at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 59] (through reference chain: com.sony.sie.kamaji.search.universal.model.openapi.UniversalSearchRequest[\"domainRequests\"]->java.util.ArrayList[0]->com.sony.sie.kamaji.search.universal.model.openapi.SearchDomainRequest[\"domain\"])",
        "reason": "invalid_parameter",
        "source": "api"
    }
}

all I tried was this:

search_obj = psnawp.search()
title_id_api = search_obj.get_title_id(title_name=trophy_title.title_name) 

NPSSO expiration date

Hi,
is there a way to see how many days left the NPSSO is valid? Currently, only 3 days before the expiration is warned. I would like to check it manually.

thx

EDIT:
When I read the following variable, I get back a json. Can I always read out the latest status or do I have to execute something first?
psnawp._request_builder.authenticator._auth_properties

{'access_token': 'access_token...',
 'token_type': 'bearer',
 'expires_in': 3599,
 'scope': 'psn:mobile.v2.core psn:clientapp',
 'id_token': 'id_token...',
 'refresh_token': 'refresh_token...',
 'refresh_token_expires_in': 5183999,
 'access_token_expires_at': 1672657895.470685}

Authentication issue: 400 Client Error: Bad Request for url

Currently getting an error code when trying to authenticate.

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://ca.account.sony.com/api/authz/v3/oauth/authorize?access_type=offline&client_id=ac8d161a-d966-4728-b0ea-ffec22f69edc&scope=psn%3Aclientapp+psn%3Amobile.v1&redirect_uri=com.playstation.PlayStationApp%3A%2F%2Fredirect&response_type=code

Query friends list of a user (besides the client)

I have seen other APIs have this feature where you can get the friends list of a user using their PlayStation ID, etc.
I don't see the reciprocal function for this in the documents for this project in the users module, I would love for this to be added or pointed out to me if I missed it. Thank you.

Limit on played games fetched changed to 200 from 500

psn fetch_played_games error : error: {"error":{"reason":"BadRequest","source":"Gamelist","code":3239940,"message":"invalid request, requested limit=500 allowed limit=200","referenceId":"2e1e8a09-6331-1031-8522-d58c84c821b7"}}

KeyError: 'location'

Seem to be getting this weird error about a location header missing when setting up the client.

03:59:46 Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.8/site-packages/rq/worker.py", line 936, in perform_job
rv = job.perform()
File "/app/.heroku/python/lib/python3.8/site-packages/rq/job.py", line 684, in perform
self._result = self._execute()
File "/app/.heroku/python/lib/python3.8/site-packages/rq/job.py", line 690, in _execute
return self.func(*self.args, **self.kwargs)
File "/app/mvp/jobs/gameaccount.py", line 225, in update_psn_account_info
client = psnawp.PSNAWP(os.getenv('PSNKEY'))
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/psnawp.py", line 13, in __init__
self.authenticator = authenticator.Authenticator(npsso_token=npsso)
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/authenticator.py", line 36, in __init__
self.authenticate()
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/authenticator.py", line 158, in authenticate
location_url = response.headers['location']
File "/app/.heroku/python/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'location'
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.8/site-packages/rq/worker.py", line 936, in perform_job
rv = job.perform()
File "/app/.heroku/python/lib/python3.8/site-packages/rq/job.py", line 684, in perform
self._result = self._execute()
File "/app/.heroku/python/lib/python3.8/site-packages/rq/job.py", line 690, in _execute
return self.func(*self.args, **self.kwargs)
File "/app/mvp/jobs/gameaccount.py", line 225, in update_psn_account_info
client = psnawp.PSNAWP(os.getenv('PSNKEY'))
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/psnawp.py", line 13, in __init__
self.authenticator = authenticator.Authenticator(npsso_token=npsso)
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/authenticator.py", line 36, in __init__
self.authenticate()
File "/app/.heroku/python/lib/python3.8/site-packages/psnawp_api/authenticator.py", line 158, in authenticate
location_url = response.headers['location']
File "/app/.heroku/python/lib/python3.8/site-packages/requests/structures.py", line 54, in __getitem__
return self._store[key.lower()][1]
KeyError: 'location'

I don't "think" my token is expired because I tried setting some logging around that but i'm hoping someone else might have another idea

requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url

Whenever I try to initialize the psnawp package, I receive this error:

requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for URL: https://ca.account.sony.com/api/authz/v3/oauth/authorize

Stack trace:

Traceback (most recent call last):
  File "/Users/diede/Code/psn-id-api/main.py", line 22, in <module>
    app.psnawp = PSNAWP(npsso)
                 ^^^^^^^^^^^^^
  File "/Users/diede/Code/psn-id-api/.venv/lib/python3.12/site-packages/psnawp_api/psnawp.py", line 40, in __init__
    self._request_builder = request_builder.RequestBuilder(authenticator.Authenticator(npsso_cookie), accept_language, country)
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/diede/Code/psn-id-api/.venv/lib/python3.12/site-packages/psnawp_api/core/authenticator.py", line 34, in __init__
    self._authenticate()
  File "/Users/diede/Code/psn-id-api/.venv/lib/python3.12/site-packages/psnawp_api/core/authenticator.py", line 112, in _authenticate
    response.raise_for_status()
  File "/Users/diede/Code/psn-id-api/.venv/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://ca.account.sony.com/api/authz/v3/oauth/authorize?access_type=offline&client_id=123456789&scope=psn%3Amobile.v2.core+psn%3Aclientapp&redirect_uri=com.scee.psxandroid.scecompcall%3A%2F%2Fredirect&response_type=code

Access Denied on client

Hi.

When running the first two steps in the ReadME I run into PSNAWPForbidden

Steps taken:
psnawp = PSNAWP('<64 character npsso code>')
client = psnawp.me()
print(client.online_id) # Error here

Any insight into why this may happen?

Is the API down?

Getting HTTP Status 429 – Too Many Requests when trying to get a session cookie.

Trophy support?

Currently here is nothing for seeing trophies a usr has and seeing the trophy list for specific games. The PHP library has it so it shouldn't be too difficult to implement here. If you want, I might be able to help :)

PSNAWPNotFound from a TrophyIterator on PS5 games

Hello, I am currently trying to use PSNAWP 2.0.0 to retrieve my trophies from the last title I played.

Unfortunately, I am no able to get the trophies for PS5 titles. The TrophyIterator returned by the method User.trophies() greets me with an error 404 as soon as I try to iterate over it. This error could be raised in the case I have no trophy for this title, yet I have quite a few of those...
For PS4 games, I am able to iterate without any issue.

Here is a code sample to illustrate what I mean:

from psnawp_api import PSNAWP

client = PSNAWP(NPSSO)

user = client.user(online_id="Frygidairus")

#Trophies from Burnout Paradise
trophies = user.trophies(
    'NPWR14842_00',
    'PS4'
)
print(next(trophies))

#Trophies from Diablo IV
trophies = user.trophies(
    'NPWR22810_00',
    'PS5'
)
print(next(trophies))

Here is the result when running the script:

Trophy(trophy_set_version='01.00', has_trophy_groups=True, trophy_id=0, trophy_hidden=False, trophy_type=<TrophyType.PLATINUM: 'platinum'>, trophy_name='Burnout Paradise Elite', trophy_detail='Awarded for successfully collecting all trophies from Burnout Paradise', trophy_icon_url='https://image.api.playstation.com/trophy/np/NPWR14842_00_007326ECF7B78940E23D1587323910E816F1620087/3974A04727EA169D039B773C21E5DD24D907218C.PNG', trophy_group_id='default', trophy_progress_target_value=None, trophy_reward_name=None, trophy_reward_img_url=None)

Traceback (most recent call last):
  File "/Users/gde/greeter/testest.py", line 21, in <module>
    print(next(trophies))

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/models/listing/pagination_iterator.py", line 45, in __next__
    return self.__iterator.__next__()

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/models/trophies/trophy.py", line 157, in fetch_next_page
    response = self.authenticator.get(url=self._url, params=params).json()

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 34, in _impl
    method_out = method(*method_args, **method_kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 283, in get
    return self.request_builder.get(**kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 143, in get
    return self.request(method="get", **kwargs)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 122, in request
    response_checker(response)

  File "/Users/gde/greeter/venv/lib/python3.10/site-packages/psnawp_api/core/request_builder.py", line 47, in response_checker
    raise PSNAWPNotFound(response.text)

psnawp_api.core.psnawp_exceptions.PSNAWPNotFound: {"error":{"referenceId":"5e2a3823-2ce6-11ef-80fc-adb49a3fbf8c","code":2240525,"message":"Resource not found"}}

As you can see, the TrophyIterator for the PS4 game return the first trophy of the list, but the PS5 TrophyIterator raises an error.

I have a hard time understanding why since I had no issue with the previous version of PSNAWP. I am trying to pin point what is happening, I will keep you updated if I find something!

{'code': 2122251, 'message': 'Ratelimit exceeded'}

Hey! Your authorization method has stopped working. Received token does not work. PSN server returns error: {'code': 2122251, 'message': 'Ratelimit exceeded'}

But if you use the authorization method through the browser, then everything is fine.

Can you solve this problem? Is there anything I can do to help?

Is creation date possible? Suggestion

I have seen some checkers on Discord and Telegram where they have a bot that shows the creation date of an account.

it looks some thing like this:
"creationDate": β€œ2023-11-15 03:04:44”

Unsupported PlatformType

Apparently, when I try to fetch a game that has a set of trophies shared between VITA and PS3, the wrapper gives me an error: ValueError: 'PS3,PSVITA' is not a valid PlatformType
This game is Batman: Arkham Origins

Getting JSONDecodeError from Authenticator.obtain_fresh_access_token

Using PSNAWP==2021.20.6, I get RequestsJSONDecodeError excedptions, raised from this line. It doesn't happen initially, but after running for some minutes, and being called multiple times, it starts and then happens repeatedly. It "feels" like a rate limit. It happens when I've made less than 100 calls to the various trophy/title endpoints in the current 15 minute window.

My intuition is that this being caused by an error response from the /authz/v3/oauth/token call [here](https://github.com/isFakeAccount/psnawp/blob/master/psnawp_api/authenticator.py#L53), but I'm not sure.

Could you advise on how I can better debug this, or the right way to handle it?

I should note, I'm using the request_builder to make calls to retrieve gaming data I don't think psnawp provides access to through other mechanisms; e.g. trophies earned, playtime information per title). I wonder if because of that, I'm retrieving access tokens too often from this line?

400 Client Error

hi. all of a sudden my client stopped authenticating.
I get and error:

File "/home/ubuntu/Projects/Python/psn_bot_new_api/new_bot.py", line 34, in <module>
    psnawp = psnawp.PSNAWP(database.getPSNToken())
  File "/home/ubuntu/Projects/Python/psn_bot_new_api/psnawp/src/psnawp_api/psnawp.py", line 40, in __init__
    authenticator.Authenticator(npsso_cookie)
  File "/home/ubuntu/Projects/Python/psn_bot_new_api/psnawp/src/psnawp_api/core/authenticator.py", line 36, in __init__
    self._authenticate()
  File "/home/ubuntu/Projects/Python/psn_bot_new_api/psnawp/src/psnawp_api/core/authenticator.py", line 123, in _authenticate
    response.raise_for_status()
  File "/usr/local/lib/python3.10/dist-packages/requests-2.28.1-py3.10.egg/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://ca.account.sony.com/api/authz/v3/oauth/authorize?access_type=offline&client_id=ac8d161a-d966-4728-b0ea-ffec22f69edc&scope=psn%3Aclientapp+psn%3Amobile.v1&redirect_uri=com.playstation.PlayStationApp%3A%2F%2Fredirect&response_type=code

can you help me fix that?

profile colour

affafaf
Is there anyway to pull another person's profile colour from just there online_id
This was more of a question than an issue

Error during message sending

Hi , during my test of your package an error occured when i have try to send private message :

Traceback (most recent call last):
  File "main.py", line 16, in <module>
    user_online_id.send_private_message("Hello World!")
  File "/home/runner/psnawp/psnawp_api/user.py", line 134, in send_private_message
    self.group = group.Group(
  File "/home/runner/psnawp/psnawp_api/group.py", line 37, in __init__
    info = self.get_by_account_ids(account_ids)
  File "/home/runner/psnawp/psnawp_api/group.py", line 80, in get_by_account_ids
    response = self.request_builder.get(
  File "/home/runner/psnawp/psnawp_api/request_builder.py", line 39, in get
    response.raise_for_status()
  File "/home/runner/psnawp/venv/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: `https://m.np.playstation.com/api/gamingLoungeGroups/v1/members/me/groups?includeFields=members%2CmainThread

did you know how fix it ? Have a good day πŸ‘

Searching PS3 and PSVita Video Games using Universal Search endpoint.

Originally posted by @glebmiller in #44

PlayStation API universal search endpoint does not return any PS3 or PSVITA games. This happens even on the app itself. Due to this the trophy_titles_for_title method cannot be used since we don't have title ids.

Note: If you get all of the trophy titles using the client.trophy_titles(limit=100) method, then it will include the PS3 and PSVITA trophies.

[Solved] Possible Issue with Authentication with PlayStation: Something went wrong while authenticating

I am experiencing some issue with authentication. I am not sure it is only happening on my account.

I'll look into it later. If you have same issue. Please comment below.

Traceback (most recent call last):
  File "/root/Bots/GamerTagIDGrabber/main.py", line 211, in <module>                          psnawp = PSNAWP(os.getenv('NPSSO_CODE'))
  File "/root/Bots/GamerTagIDGrabber/venv/lib/python3.10/site-packages/psnawp_api/psnawp.py", line 39, in __init__
    self._request_builder = request_builder.RequestBuilder(authenticator.Authenticator(npsso_cookie))                                                                                 File "/root/Bots/GamerTagIDGrabber/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 34, in __init__                                                          self._authenticate()
  File "/root/Bots/GamerTagIDGrabber/venv/lib/python3.10/site-packages/psnawp_api/core/authenticator.py", line 120, in _authenticate
    raise psnawp_exceptions.PSNAWPAuthenticationError("Something went wrong while authenticating")
psnawp_api.core.psnawp_exceptions.PSNAWPAuthenticationError: Something went wrong while authenticating

A few new endpoints

So, Sony added PlayStation Stars as a new feature and I got a couple endpoints + a trophy summary that I can't recall if it is already documented, so I'm posting it.

URL: https://m.np.playstation.com/api/trophy/v1/users/6583328133141612059/trophySummary

Response:
{ "accountId": "6583328133141612059", "trophyLevel": 302, "progress": 85, "tier": 4, "earnedTrophies": { "bronze": 1883, "silver": 496, "gold": 112, "platinum": 31 } }

URL:
https://m.np.playstation.com/api/graphql/v1/op?operationName=metGetCollectibleDisplay&variables=%7B%22accountId%22%3A%6583328133141612059%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%220299b65abf4385e097e6848d14b0423df5464632855c330bdd002dfc42f4c71e%22%7D%7D

Response:
{ "data": { "loyaltyCollectibleDisplayRetrieve": { "__typename": "LoyaltyCollectibleDisplay", "collectibles": [ { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-0", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-1", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-2", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-3", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-4", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-5", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-6", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-7", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-8", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-9", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-10", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-11", "isEmpty": true } ], "isEmpty": true, "isFull": false, "selectedScene": { "__typename": "LoyaltyCollectibleScene", "assets": [ { "__typename": "Media", "role": "BACKGROUND", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/ice_background.png" }, { "__typename": "Media", "role": "TILE", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/Ice_Tile.png" }, { "__typename": "Media", "role": "PREVIEW", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/Ice_Preview.png" } ], "id": "a68f1a18-de00-429d-b4dc-d0bc66b748c7" } } } }

URL:
https://m.np.playstation.com/api/graphql/v1/op?operationName=metGetAccount&variables=%7B%22accountId%22%3A%6583328133141612059%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22743c32289cdd6fbdead3b34ea80b48d63f8ddab34581469c4dda4ea412e6cf6b%22%7D%7D

RESPONSE:
{ "data": { "loyaltyAccountRetrieve": { "__typename": "LoyaltyAccount", "collectibleScene": { "__typename": "LoyaltyCollectibleScene", "assets": [ { "__typename": "Media", "role": "BACKGROUND", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/ice_background.png" }, { "__typename": "Media", "role": "TILE", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/Ice_Tile.png" }, { "__typename": "Media", "role": "PREVIEW", "url": "https://sky-assets.api.playstation.com/sky/p1-np/collectibleScene/image/Ice_Preview.png" } ], "id": "a68f1a18-de00-429d-b4dc-d0bc66b748c7" }, "collectibles": [ { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-0", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-1", "isEmpty": true }, { "__typename": "LoyaltyCollectibleDisplayItem", "assets": null, "id": "empty-slot-2", "isEmpty": true } ], "enrollStatus": { "__typename": "LoyaltyEnrollStatus", "enrolledDateTime": "2022-10-13T08:59:04.115184Z", "isUserEligibleToEnroll": true, "isUserEnrolled": true, "status": "ENROLLED" }, "pointsBalance": null, "requiresTosAcceptance": null, "statusLevel": { "__typename": "LoyaltyStatusLevel", "currentStatusLevel": "Sapphire", "expiryDate": null, "nextStatusProgress": 0, "statusLevelNumber": 1, "totalPurchaseEarned": 0, "totalPurchaseNeeded": 1, "totalTrophiesEarned": 0, "totalTrophiesNeeded": 1 } } } }

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.