PSNAWP


NamePSNAWP JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/isFakeAccount/psnawp
SummaryPython API Wrapper for PlayStation Network API
upload_time2024-07-14 04:16:07
maintainerNone
docs_urlNone
authorisFakeAccount
requires_python<4.0,>=3.9
licenseMIT
keywords psn playstation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # <img src="docs/_static/psn_logo.png" alt="PlayStation Logo" height="35px"> PlayStation Network API Wrapper Python (PSNAWP)

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

[![PyPI version](https://badge.fury.io/py/PSNAWP.svg)](https://badge.fury.io/py/PSNAWP)
[![Downloads](https://static.pepy.tech/badge/psnawp)](https://www.pepy.tech/projects/psnawp)
[![python-logo](https://img.shields.io/badge/python-3.9_|_3.10_|_3.11_|_3.12-blue.svg)](https://www.python.org/)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![Documentation Status](https://readthedocs.org/projects/psnawp/badge/?version=latest)](https://psnawp.readthedocs.io/en/latest/?badge=latest)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![pre-commit](https://github.com/isFakeAccount/psnawp/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/isFakeAccount/psnawp/actions/workflows/pre-commit.yaml)
[![pytest](https://github.com/isFakeAccount/psnawp/actions/workflows/pytest.yaml/badge.svg)](https://github.com/isFakeAccount/psnawp/actions/workflows/pytest.yaml)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/MIT)

<!-- Pytest Coverage Comment:Begin -->
\n<!-- Pytest Coverage Comment:End -->

## 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](https://my.playstation.com/) 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

```json
{"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

```py
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/isFakeAccount/psnawp",
    "name": "PSNAWP",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "PSN, PlayStation",
    "author": "isFakeAccount",
    "author_email": "trevorphillips@gmx.us",
    "download_url": "https://files.pythonhosted.org/packages/d9/d9/68a919b7e0c3bb12ecbf68da26a6a3cdf82da3f7b0f6610fb3978a4d1e19/psnawp-2.1.0.tar.gz",
    "platform": null,
    "description": "# <img src=\"docs/_static/psn_logo.png\" alt=\"PlayStation Logo\" height=\"35px\"> PlayStation Network API Wrapper Python (PSNAWP)\n\nRetrieve User Information, Trophies, Game and Store data from the PlayStation Network\n\n[![PyPI version](https://badge.fury.io/py/PSNAWP.svg)](https://badge.fury.io/py/PSNAWP)\n[![Downloads](https://static.pepy.tech/badge/psnawp)](https://www.pepy.tech/projects/psnawp)\n[![python-logo](https://img.shields.io/badge/python-3.9_|_3.10_|_3.11_|_3.12-blue.svg)](https://www.python.org/)\n[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n[![Documentation Status](https://readthedocs.org/projects/psnawp/badge/?version=latest)](https://psnawp.readthedocs.io/en/latest/?badge=latest)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![pre-commit](https://github.com/isFakeAccount/psnawp/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/isFakeAccount/psnawp/actions/workflows/pre-commit.yaml)\n[![pytest](https://github.com/isFakeAccount/psnawp/actions/workflows/pytest.yaml/badge.svg)](https://github.com/isFakeAccount/psnawp/actions/workflows/pytest.yaml)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/MIT)\n\n<!-- Pytest Coverage Comment:Begin -->\n\\n<!-- Pytest Coverage Comment:End -->\n\n## How to install\n\n### From PyPI\n\n```\npip install PSNAWP\n```\n\n## Important Links\n> PyPI: https://pypi.org/project/PSNAWP/\n>\n> Read the Docs: https://psnawp.readthedocs.io/en/latest/\n\n## Getting Started\n\n> [!CAUTION]\n> 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.\n>\n> 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.\n\nTo get started you need to obtain npsso <64 character code>. You need to follow the following steps\n\n1. Login into your [My PlayStation](https://my.playstation.com/) account.\n2. In another tab, go to `https://ca.account.sony.com/api/v1/ssocookie`\n3. If you are logged in you should see a text similar to this\n\n```json\n{\"npsso\":\"<64 character npsso code>\"}\n```\nThis 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.\n\nFollowing is the quick example on how to use this library\n\n```py\nfrom psnawp_api import PSNAWP\nfrom psnawp_api.models import SearchDomain\nfrom psnawp_api.models.trophies import PlatformType\n\npsnawp = PSNAWP(\"<64 character npsso code>\")\n\n# Your Personal Account Info\nclient = psnawp.me()\nprint(f\"Online ID: {client.online_id}\")\nprint(f\"Account ID: {client.account_id}\")\nprint(f\"Profile: {client.get_profile_legacy()} \\n\")\n\n# Your Registered Devices\ndevices = client.get_account_devices()\nfor device in devices:\n    print(f\"Device: {device} \\n\")\n\n# Your Friends List\nfriends_list = client.friends_list()\nfor friend in friends_list:\n    print(f\"Friend: {friend} \\n\")\n\n# Your Players Blocked List\nblocked_list = client.blocked_list()\nfor blocked_user in blocked_list:\n    print(f\"Blocked User: {blocked_user} \\n\")\n\n# Your Friends in \"Notify when available\" List\navailable_to_play = client.available_to_play()\nfor user in available_to_play:\n    print(f\"Available to Play: {user} \\n\")\n\n# Your trophies (PS4)\nfor trophy in client.trophies(\"NPWR22810_00\", PlatformType.PS4):\n    print(trophy)\n\n# Your Chat Groups\ngroups = client.get_groups()\nfirst_group_id = None  # This will be used later to test group methods\nfor id, group in enumerate(groups):\n    if id == 0:  # Get the first group ID\n        first_group_id = group.group_id\n\n    group_info = group.get_group_information()\n    print(f\"Group {id}: {group_info} \\n\")\n\n# Your Playing time (PS4, PS5 above only)\ntitles_with_stats = client.title_stats()\nfor title in titles_with_stats:\n    print(\n        f\" \\\n        Game: {title.name} - \\\n        Play Count: {title.play_count} - \\\n        Play Duration: {title.play_duration} \\n\"\n    )\n\n\n# Other User's\nexample_user_1 = psnawp.user(online_id=\"VaultTec-Co\")  # Get a PSN player by their Online ID\nprint(f\"User 1 Online ID: {example_user_1.online_id}\")\nprint(f\"User 1 Account ID: {example_user_1.account_id}\")\n\nprint(example_user_1.profile())\nprint(example_user_1.prev_online_id)\nprint(example_user_1.get_presence())\nprint(example_user_1.friendship())\nprint(example_user_1.is_blocked())\n\n# Example of getting a user by their account ID\nuser_account_id = psnawp.user(account_id=\"9122947611907501295\")\nprint(f\"User Account ID: {user_account_id.online_id}\")\n\n\n# Messaging and Groups Interaction\ngroup = 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\nprint(group.get_group_information())\nprint(group.get_conversation(10))  # Get the last 10 messages in the group\nprint(group.send_message(\"Hello World\"))\nprint(group.change_name(\"API Testing 3\"))\n# print(group.leave_group()) # Uncomment to leave the group\n\n# Create a new group with other users - i.e. 'VaultTec-Co' and 'test'\nexample_user_2 = psnawp.user(online_id=\"test\")\nnew_group = psnawp.group(users_list=[example_user_1, example_user_2])\nprint(new_group.get_group_information())\n# You can use the same above methods to interact with the new group - i.e. send messages, change name, etc.\n\n# Searching for Game Titles\nsearch = psnawp.search(search_query=\"GTA 5\", search_domain=SearchDomain.FULL_GAMES)\nfor search_result in search:\n    print(search_result[\"result\"][\"invariantName\"])\n\n ```\n\n**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.**\n\n## Contribution\n\nAll 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.\n\n## Disclaimer\n\nThis 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.\n\n## Credit\n\nThis 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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python API Wrapper for PlayStation Network API",
    "version": "2.1.0",
    "project_urls": {
        "Documentation": "https://psnawp.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/isFakeAccount/psnawp",
        "Repository": "https://github.com/isFakeAccount/psnawp"
    },
    "split_keywords": [
        "psn",
        " playstation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "302b1e1922d0090ccb39101bb64b585a355884978a73e8747f6cd6cb3d3cbfdc",
                "md5": "f0a8113e72d1ebeade37b543a957ec5d",
                "sha256": "2ff484b971bc50103893310d893072ea4c740f63ab881f90eac32e3a9fae88eb"
            },
            "downloads": -1,
            "filename": "psnawp-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0a8113e72d1ebeade37b543a957ec5d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 45533,
            "upload_time": "2024-07-14T04:16:05",
            "upload_time_iso_8601": "2024-07-14T04:16:05.689789Z",
            "url": "https://files.pythonhosted.org/packages/30/2b/1e1922d0090ccb39101bb64b585a355884978a73e8747f6cd6cb3d3cbfdc/psnawp-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9d968a919b7e0c3bb12ecbf68da26a6a3cdf82da3f7b0f6610fb3978a4d1e19",
                "md5": "4cda843f97461a9a47920f3f9a5e65d5",
                "sha256": "aa624cd486d2ace512d649e462a43c28d882958d1c9421350ed25ca728b2e90e"
            },
            "downloads": -1,
            "filename": "psnawp-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4cda843f97461a9a47920f3f9a5e65d5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 35504,
            "upload_time": "2024-07-14T04:16:07",
            "upload_time_iso_8601": "2024-07-14T04:16:07.827341Z",
            "url": "https://files.pythonhosted.org/packages/d9/d9/68a919b7e0c3bb12ecbf68da26a6a3cdf82da3f7b0f6610fb3978a4d1e19/psnawp-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-14 04:16:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "isFakeAccount",
    "github_project": "psnawp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "psnawp"
}
        
Elapsed time: 7.64447s