-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is missing from psn-api? #34
Comments
I would like a way to see if a user has the friends list set to public and I would like a way to see if a user has friended another user which I specify |
@net-tech @LoriKarikari 👋 Thanks for your interest in psn-api. I'm happy to release this feature in 2.6.0 with a new function call: Here is a demo of how to use it to solve the given problem: check to see if a user's friends list is public and if they've added another user as a friend. import {
exchangeCodeForAccessToken,
exchangeNpssoForCode,
getUserFriendsAccountIds,
makeUniversalSearch
} from "psn-api";
async function main(firstUserName: string, secondUserName: string) {
// Before doing anything, we have to authenticate.
// Read the docs on the authentication process if this is unclear.
const myNpsso = process.env.NPSSO ?? "";
const accessCode = await exchangeNpssoForCode(myNpsso);
const authorization = await exchangeCodeForAccessToken(accessCode);
// Our function takes two usernames as its arguments.
// We're going to see if those two given usernames are friends.
// First, we need to retrieve both of their PSN `accountId` values.
const firstSearchResponse = await makeUniversalSearch(
authorization,
firstUserName,
"SocialAllAccounts"
);
const secondSearchResponse = await makeUniversalSearch(
authorization,
secondUserName,
"SocialAllAccounts"
);
// This is very naive and just for demo purposes.
// I'm assuming both of the given users exist and are the first result in our searches.
const firstFoundUser = firstSearchResponse.domainResponses[0].results[0];
const secondFoundUser = secondSearchResponse.domainResponses[0].results[0];
try {
// Get the first user's friends list. It's just an array of `accountId` values.
// Note that this will throw an error if the user's friends list is set to private.
const firstFriendsListResponse = await getUserFriendsAccountIds(
authorization,
firstFoundUser.socialMetadata.accountId
);
// Is the second user's `accountId` in the array? If so, they're friends.
if (
firstFriendsListResponse.friends.includes(
secondFoundUser.socialMetadata.accountId
)
) {
console.log("🥳 The two given users are friends!!");
}
} catch {
throw new Error(
`🥺 ${firstUserName} has their friends list set to private.`
);
}
} |
Thats amazing! |
#12 would be awesome. The IGDB API (https://api-docs.igdb.com/#about) doesn't currently have a unique PSN identifier for entries in its database and I'd love to be able to tie the two together and doing it via title + platform alone is a bit messy because there non-perfect data on both sides. |
Can we also have method for sending/reading messages and auto obtaining auth codes in order to create a fully working chatbot in PSN? |
Hi @VityaSchel By auto-obtaining auth codes, do you mean auto-obtaining an NPSSO? This will take some investigation, as this appears to be the only layer of Sony's PSN API that has active bot/script detection & prevention. I have been able to do this using Playwright but that obviously is not very practical. Sending & reading messages should be doable. I'll add it to my list. |
I mean, refreshing npsso. You know, I don't relogin in ps-app, but I believe npsso has expiry date, so there must be some method of refreshing them. Also please add to your checklist methods listed in PSNjs package. Login probably does not work because last commit was 6 years ago, but you can take other methods such as sending and reading messages from source code of the PSNjs package. Thanks for your answer. |
I would really use the playtime calculation for games. As far as I remember it is only availalbe in PS5 games but still it would be really nice to have. I think this endpoint should provide the information |
The endpoint provides the information (so we should add it!), but bear in mind I believe this endpoint is not entirely accurate. Pretty sure this is why PS-Timetracker relies on a bot added to the user's friendlist (we should support all of this behavior too tbh). |
I was just going to propose the adding to friends things. If possible. Since it will allow getting trophy information without changing privacy settings that much. So I am happy to see that is something considered for the future |
Hey, can we get the last played games? Thanks, awesome work! |
Hi! Though not perfect (I believe PSN does have a recent games endpoint), you can get pretty close by finding what the most recently earned trophy was. Here's some sample code if you're interested in going down this route: |
I'm using it this way, ;), the only problem with this method, sometimes the last trophy earned is not the last game I played. |
It would be beneficial to have a way to load data based on |
I would like for it to be a way to get the trophy info about a specific game that a user has played with a title id (CUSA, PPSA, BLUS, etc). I know that this is possible in the current api (at least for PS4 and PS5 titles) given that it is documented here and it is used in the psn-php wrapper here. I think it would be an easy add given that the endpoint is already wrapped and you can add the npTitleIds as an optional parameter. This would give the user access to data like the infamous |
In the friends list in the PS app, it shows a status for each online friend. This status is usually the name of a game, and for certain games, information about what the user is doing in game. For example, in the picture, my friend is playing Uncharted 4 and is In Matchmaking. Would it be possible to get this status string? |
I'd love to have a possibility to retrieve playtime for every game the user has played. I did a small research and I guess this should be doable. And I do believe this'd be a good addition to the package. |
@alekpentchev what came from your research? Did you discover which API calls are used to acquire this information? If so I might be able to (help you) create a PR which adds this functionality. |
Unfortunately the The psnawp library references a different route that does support presence for both platforms. What's holding me back to create a PR and add a specific presence function using this API is my lack of familiarity with Redis. If anyone wants to collab on this change DM me on twitter. |
Getting a list of all games in a user's library (including all games with zero playtime) would be nice. |
For reference, I believe this is the updated link (feel free to correct me).
Like getting their purchased games? Does PSN even share that information at all?
We would need to look into how PS-Timetracker handles this, as they accept friend requests instantly and track their data, later sending them the time played summary.
Me and @wescopeland talked briefly about this on #118, so I guess this part will be happening sometime next month, at the latest. Regarding the messaging system, we gotta look into it to see if we can access the endpoint related to that from your provided link. Just be aware that you need to run your backend on a server since PSN will throw CORS errors if you try to handle everything in the browser (reference: #77 and #109). Thanks for the PSNjs package reference, we gonna look into it.
Considering you have the ID beforehand, right? Because I don't think we can make the request to a profile without knowing their ID. The best would be to wrap both methods under the hood for you, AFAIK, but that would just be convenient. Maybe wes would know more about it.
Correct me if I misunderstood your question, but you want the last played games, regardless of when their trophies were obtained, right? Like Exophase does? (game references are The Division 1 and PvZ GW2) Regarding all replies, I'll see an issue opened for each of them that still lacks one so we can more easily track each individual progress. |
@wescopeland what do you think of this request? Should we add this to the library or leave it for users to implement themselves? Let me know so I can open an associated issue for it or not. I personally made another request to fetch more games using offset if my first request pulled the exact number I received. I kept looping that request until a request retrieved less than the max I asked for or gave a Resource Not Found error, then counted the total games and built the pagination using that. EDIT: I see the user made the commit that solves this issue and just wasn't acknowledged here. Disregard previous message and good job on the contribution! |
I believe I've opened related issues to every suggestion so far, up to February 28th, 2023. Feel free to reply to me if you suggested something that I've missed, or instead, directly open an issue for your request. |
@dillysfriend Just FYI, this is being tracked at #99, so you can follow that issue to be up to date with the progress, if you still need this feature. |
Is it possible to get a list of all user's games? |
One thing I'm missing is to be able to query a user their games with a filter e.g. by passing a game ID instead of having to fetch all their games, possibly multiple calls due to a large amount of games in their list and then having to filter out a single game after all that. I'm not sure how feasible this is, since this is basically something I wish PSN implemented a long time ago in the app too. A simple 'search bar' would do wonders. |
There are a ton of endpoints left to add. Are there any new features you'd like to see prioritized in the library? If so, let me know here!
The text was updated successfully, but these errors were encountered: