N
pip install PSNAWP
PyPI: https://pypi.org/project/PSNAWP/
문서 읽기: https://psnawp.readthedocs.io/en/latest/
주의
이 라이브러리는 PSN(PlayStation Network)용 비공식 리버스 엔지니어링 API 래퍼입니다. PSN 안드로이드 앱의 리버스 엔지니어링을 기반으로 개발되었습니다. API 래퍼(>= v2.1.0)는 15분당 요청 300개로 자체 속도 제한을 설정합니다. 그러나 이 API를 사용하여 대량 요청을 보내지 않는 것이 여전히 중요합니다. API를 과도하게 사용하면 PSN 계정이 일시적 또는 영구적으로 금지될 수 있습니다.
최악의 경우 비디오 게임 및 진행 상황과 함께 기본 계정에 대한 액세스 권한을 잃지 않도록 이 라이브러리를 사용하기 위한 전용 계정을 만들 수도 있습니다.
시작하려면 npsso <64자 코드>를 얻어야 합니다. 다음 단계를 따라야 합니다.
https://ca.account.sony.com/api/v1/ssocookie
로 이동합니다.{ "npsso" : " <64 character npsso code> " }
이 npsso 코드는 인증 목적으로 API에서 사용됩니다. npsso에서 생성된 새로 고침 토큰은 약 2개월 동안 지속됩니다. 그 후에는 새로운 npsso 토큰을 받아야 합니다. 새로 고침 토큰 만료 기간이 3일 미만 남은 경우 봇은 경고를 인쇄합니다.
다음은 이 라이브러리를 사용하는 방법에 대한 간단한 예입니다.
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" ])
참고: psnawp의 여러 인스턴스를 생성하려면 별도의 PSN 계정에서 npsso 코드를 가져와야 합니다. 동일한 계정으로 새 npsso를 생성하면 이전 npsso가 즉시 만료됩니다.
모든 버그 재게시 및 기능 요청을 환영합니다. 비록 제가 Python 라이브러리를 만드는 것이 처음이라 일부 기능을 구현하는 데 시간이 걸릴 수 있습니다. 제가 하는 일이 관습에 얽매이지 않는 방식이라면 제안을 환영합니다.
이 프로젝트는 스팸, 남용 또는 이와 유사한 용도로 사용되도록 의도되지 않았습니다. 이러한 목적으로 이 프로젝트를 사용하는 것은 승인되지 않습니다. 이 API 래퍼를 사용하여 애플리케이션을 생성할 때 이 점을 염두에 두십시오.
이 프로젝트에는 Python으로 변환된 PlayStationNetwork::API 및 PSN-PHP 래퍼의 코드가 포함되어 있습니다. 또한 PlayStation Trophy 엔드포인트를 문서화해준 @andshrew에게도 특별히 감사드립니다. 모든 라이센스는 이 저장소에 포함되어 있습니다.