Closed joekw closed 2 years ago
Hi @joekw
Have a look at https://m.np.playstation.net/api/gamelist/v2/users/me/titles
You can authenticate to it using the example from the trophy documentation. As with other endpoints me
can be substituted with another accounts accountId
to view their list.
This returns a playDuration
for each of the games you've played and this is in a time duration format. eg PT67H40M2S
If you're using Powershell you can further convert this to a format which is easier to work with using [Xml.XmlConvert]::ToTimeSpan("PT67H40M2S")
so the above then becomes:
Days : 2
Hours : 19
Minutes : 40
Seconds : 2
Milliseconds : 0
Ticks : 2436020000000
TotalDays : 2.81946759259259
TotalHours : 67.6672222222222
TotalMinutes : 4060.03333333333
TotalSeconds : 243602
TotalMilliseconds : 243602000
wow, awesome, thanks a lot!
Hi @andshrew Any idea how I can get the next offset for the hours played? The endpoint response is something like this
{
"titles": [...],
"nextOffset": 10,
"previousOffset": 0,
"totalItemCount": 6211
}
I want to access the nextOffset
Thanks!
This info should be added into the documentation imho, it's interesting data.
@Dev-R
You need to use the offset parameter in your subsequent requests. So after your initial request tells you that the next offset is 10, then you make another one like this:
https://m.np.playstation.com/api/gamelist/v2/users/me/titles?offset=10
You'll get a response like:
{
"titles": [...],
"nextOffset": 20,
"previousOffset": 9,
"totalItemCount": 6211
}
You can also increase has many it returns at once using limit. I'm not sure what the upper limit is off hand.
https://m.np.playstation.com/api/gamelist/v2/users/me/titles?offset=10&limit=25
{
"titles": [...],
"nextOffset": 35,
"previousOffset": 9,
"totalItemCount": 6211
}
@Ragowit I'll see about adding misc endpoints into the documentation when I get a chance, there's a few that are probably worth adding which are buried in the issues here.
Just to add another endpoint you can use for play time. This one gives you the time played as whole hours, but its limited to the 200 most recently played titles:
https://m.np.playstation.com/api/graphql/v1/op?operationName=metGetRecentPlayedTitles&variables={"accountId":"me","count":200,"categories":"ps4_game,ps5_native_game,pspc_game","shouldFetchActivityHelp":false,"shouldFetchCodex":false}&extensions={"persistedQuery":{"version":1,"sha256Hash":"29a5622efc85273ef5db6fb7c93ab0c24358dc49a39e1d12e6b4eae9042aa36e"}}
You can open this directly in your browser after signing into the PS Store. me
can be another accounts id.
{
"data": {
"recentPlayedTitlesRetrieve": [
{
"__typename": "PlayedTitle",
"id": "PPSA07950_00",
"npTitleId": "PPSA07950_00",
"playTimeHours": 329,
"title": {
"__typename": "Title",
"conceptId": "10001130",
"media": [
{
"__typename": "Media",
"role": "FOUR_BY_THREE_BANNER",
"type": "IMAGE",
"url": "https://image.api.playstation.com/vulcan/ap/rnd/202406/1421/0be1d2f58e5cd28643898841d8f226dc7d01aa684ef29e49.png"
}
],
"name": "Call of Duty®",
"platform": "PS5"
}
}
The PS5 can show the hours played for all your games (PS3, PS4, PS5). I assume there's an API endpoint for this and would love to find out what it is. Potentially only possible if the PS5 is jailbroken in order to MITM the traffic.