Giter VIP home page Giter VIP logo

psnawp's Introduction

PlayStation Network API Wrapper Python (PSNAWP)

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

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  

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.PSNAWP('<64 character npsso code>')   

# Client that is you  
client = psnawp.me()
print(client.get_online_id())
print(client.get_account_id())
print(client.get_account_devices())
print(client.get_friends())
print(client.blocked_list())

# Getting user from online
user_online_id = psnawp.user(online_id="VaultTec_Trading")
print(user_online_id.online_id)
print(user_online_id.account_id)
print(user_online_id.profile())
print(user_online_id.get_presence())
print(user_online_id.friendship())
print(user_online_id.is_available_to_play())
print(user_online_id.is_blocked())

# Sending Message
user_online_id.send_private_message("Hello World!")
messages = user_online_id.get_messages_in_conversation(message_count=1)
# If you want to leave the conversation
user_online_id.leave_private_message_group()

# Getting user from Account ID
user_account_id = psnawp.user(account_id='1802043923080044300')
# Same functions as shown above

Sending private message only works if the message group between you and user already exists otherwise it will throw HTTP Status Code 429. Basically you would have to create the group yourself through the APP or ask the user to send you message first.

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

psnawp's People

Contributors

isfakeaccount avatar

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.