achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
263 stars 31 forks source link

Missing examples of how to get titleId from universalSearch #88

Open GusAV opened 2 years ago

GusAV commented 2 years ago

Hi, I'm trying to understand how do you get a Title Id from the universal search since all requests require the Title Id and not the Title Name, the only example I see as option is "SocialAllAccounts", but I'm not aiming to make searches on users, just games.

I know one option is to get the titles for the user and iterate through all of them, making extra requests for the pagination, but this feels pretty much overkill to just find a title Id.

Appreciate the help, thanks.

isFakeAccount commented 1 year ago

https://psnawp.readthedocs.io/en/latest/psnawp_api.models.html#psnawp_api.models.search.Search.universal_search

This should give you some idea. "conceptProductMetadata" contains the "title_id". I'd imagine this API is more or less the same.

I haven't included the "conceptProductMetadata" in docs because it is a massive dict.

image

TheYuriG commented 1 year ago

OK, so I've recreated the endpoint that @isFakeAccount mentioned and goddamn, the "massive dict" statement wasn't a joke.

Good news and bad news, let's start with the bad ones since it's quicker to get through:

Bad news: I can't seem to find the trophy list unique identifier (which I assumed is what you wanted to get, in order to use the other commands?). Those follow the format NPWR[insert 5 unique digits here]_00 and I couldn't seem to find them in the data returned (you can try below, if you want). However...

Good news: this endpoint returns A LOT of information, which can be really useful if you want to build something else entirely, like a games library or have the PSN Store Rating attached to your trophy lists or whatever else you might want. I'll paste below the first result for the search "dark souls":

{
        id: '201190:UP0700-CUSA03388_00-DARKSOULS3000000',
        type: 'conceptProduct',
        univexId: 'search.no_experiment.non.0.non',
        experimentData: ['search.no_experiment.non.0.non'],
        score: 196.13864,
        conceptProductMetadata: {
            id: 'UP0700-CUSA03388_00-DARKSOULS3000000',
            country: 'BR',
            language: 'pt',
            conceptId: 201190,
            titleId: 'CUSA03388_00',
            name: 'DARK SOULS™ III',
            nameEn: 'DARK SOULS™ III',
            phoneticPronunciation: '',
            spokenName: '',
            minimumAge: 14,
            type: 'GAME.FULL_GAME',
            storeClassification: 'GAME',
            storePrimaryClassification: 'PREMIUM_GAME',
            storeSubClassification: 'NA',
            storeDisplayClassification: 'FULL_GAME',
            localizedStoreDisplayClassification: 'Jogo completo',
            topCategory: 'GAME',
            localizedTopCategory: 'Jogo',
            edition: {
                name: '',
                nameEn: '',
                phoneticPronunciation: '',
                spokenName: '',
                type: 'OTHER',
                features: [],
            },
            isDefaultProduct: true,
            isBestSelling: false,
            descriptions: [
                {
                    type: 'LEGAL',
                    desc: 'Para jogar esse jogo no PS5, talvez seja preciso atualizar seu sistema com o software do sistema mais recente. É possível jogar esse jogo no PS5, mas  alguns recursos disponíveis no PS4 podem estar ausentes. Consulte PlayStation.com/bc para obter mais detalhes.',
                    metadata: {
                        subType: 'BC_DISCLOSURE',
                    },
                },
                {
                    type: 'LONG',
                    desc: "Premiado como 'Melhor RPG' na Gamescom 2015 e com mais de 35 prêmios e indicações na E3 2015, DARK SOULS™ III continua a elevar o patamar de uma das séries mais inovadoras e aclamadas pela crítica.<br/>Com o fogo se apagando e o mundo caindo em ruínas, você precisa se aventurar em um universo repleto de inimigos e ambientes colossais. Jogadores entrarão em um mundo de trevas e atmosfera épica, com uma jogabilidade mais ágil e combates mais intensos. Veteranos e novatos vão mergulhar na jogabilidade gratificante e nos gráficos envolventes que são a marca registrada do jogo.<br/>Agora só restam cinzas... Prepare-se para abraçar a escuridão mais uma vez!<br/><br/><br/><br/>O sistema PlayStation®Vita é necessário para o Uso remoto.<br/><br/>O uso das contas da PSN e da SEN está sujeito aos Termos de serviço, ao Contrato do usuário e à política de privacidade aplicável (consulte os termos em sonyentertainmentnetwork.com/terms-of-service & sonyentertainmentnetwork.com/privacy-policy). *Para jogar online com vários jogadores, também é necessária uma assinatura do PlayStation®Plus.<br/><br/>",
                },
                {
                    type: 'COMPATIBILITY_NOTICE',
                    desc: 'PS Plus necessário para o jogo online<br/>Compatível com até 6 jogadores online com o PS Plus<br/>Jogo online opcional<br/>1 jogadores<br/>Compatível com Uso remoto<br/>Vibração do DUALSHOCK 4',
                },
                {
                    type: 'LEGAL',
                    desc: '<br><br>É preciso ter uma conta para usar os recursos online, que estão sujeitos aos termos de serviço e à política de privacidade aplicável (playstationnetwork.com/terms-of-service e playstationnetwork.com/privacy-policy).<br><br>Software sujeito à licença e à garantia limitada (us.playstation.com/softwarelicense/br).<br>',
                    metadata: {
                        downloadCloudFlag: 'BOTH',
                        subType: 'SCEA_TOS',
                    },
                },
                {
                    type: 'LEGAL',
                    desc: '<br> A taxa única de licença dá o direito de jogar no sistema PS4™ principal designado e outros sistemas PS4™ quando está usando essa conta.<br>',
                    metadata: {
                        downloadCloudFlag: 'DOWNLOAD',
                        subType: 'SCEA_PS4_DRM',
                    },
                },
                {
                    type: 'LEGAL',
                    desc: '<br/>Dark Souls™ III & ©BANDAI NAMCO Entertainment Inc. / ©2011-2016 FromSoftware, Inc.<br/>',
                },
            ],
            contentRating: {
                authority: 'ClassInd',
                description: 'ClassInd 14+',
                name: 'CLASSIND_14',
                url: 'https://image.api.playstation.com/grc/images/ratings/hd/classind/14.png',
                descriptors: [
                    {
                        description: 'Violência',
                        name: 'CLASSIND_VIOLENCIA',
                    },
                ],
                interactiveElements: [],
            },
            media: {
                videos: [
                    {
                        id: '733380',
                        url: 'https://apollo2.dl.playstation.net/cdn/UP0700/CUSA03388_00/FREE_CONTENTEibUbN3CI4lnHJNIzEwW/PREVIEW_GAMEPLAY_VIDEO_109885.mp4',
                        hlsUrl: 'http://d1v33d7b5ul6gp.cloudfront.net/1204972/PREVIEW_GAMEPLAY_VIDEO_109885_playlist.m3u8',
                        posters: [
                            'https://image.api.playstation.com/transcode/1204972/frame_0000.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0001.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0002.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0003.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0004.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0005.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0006.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0007.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0008.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0009.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0010.jpg',
                            'https://image.api.playstation.com/transcode/1204972/frame_0011.jpg',
                        ],
                        type: 'PREVIEW',
                    },
                ],
                images: [
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/yZAswaCjMOV3bOase0iDGtt7rxrkeSH9.jpg',
                        type: 'BACKGROUND',
                    },
                    {
                        url: 'https://image.api.playstation.com/vulcan/img/rnd/202010/0822/zA0pyOR4JXOtGGIY7Jp2FJZP.png',
                        type: 'GAMEHUB_COVER_ART',
                    },
                    {
                        url: 'https://image.api.playstation.com/vulcan/img/rnd/202010/0822/0p6wO8PkVsDjPntPBcsHSkOA.png',
                        type: 'LOGO',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTh65Tw4Da49pv6wdNcNvC/PREVIEW_SCREENSHOT1_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENT3uND3cPw2Hef98OBiza6/PREVIEW_SCREENSHOT2_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENT8yEPnEwo9xU30hJh2GfV/PREVIEW_SCREENSHOT3_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTtOO2KqK2aT0IDkIMscas/PREVIEW_SCREENSHOT4_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTmHkp4o64tleQYPoqqTFq/PREVIEW_SCREENSHOT5_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENThDGZAaODfQd6FD3WtARL/PREVIEW_SCREENSHOT6_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTYdSD15cvaG6Jp1TBe0Yb/PREVIEW_SCREENSHOT7_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTtlbF0LmdA0CgtFkowOK6/PREVIEW_SCREENSHOT8_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENT4x8t0cuIjO8qSG1CP74m/PREVIEW_SCREENSHOT9_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/FREE_CONTENTOlNF2F933Ccc74vVe2Vj/PREVIEW_SCREENSHOT10_109885.jpg',
                        type: 'SCREENSHOT',
                    },
                    {
                        url: 'https://image.api.playstation.com/cdn/UP0700/CUSA03388_00/v8JlD8KcQUtTqaLBmpFnj1ESRR5zMkLk.png',
                        type: 'MASTER',
                    },
                ],
            },
            genres: ['ACTION', 'ADVENTURE', 'ROLE_PLAYING_GAMES'],
            localizedGenres: [
                {
                    value: 'Ação',
                    type: 'ACTION',
                },
                {
                    value: 'Aventura',
                    type: 'ADVENTURE',
                },
                {
                    value: 'RPG',
                    type: 'ROLE_PLAYING_GAMES',
                },
            ],
            subGenres: ['3D_FIGHTING', 'EPIC', 'EPIC'],
            localizedSubGenres: [
                {
                    value: 'Combate 3D',
                    type: '3D_FIGHTING',
                },
                {
                    value: 'Épico',
                    type: 'EPIC',
                },
                {
                    value: 'Épico',
                    type: 'EPIC',
                },
            ],
            releaseDate: '2016-04-12T03:00:00Z',
            localizedReleaseDate: '2016-04-12',
            isRecommendableOnStore: true,
            isSearchableOnStore: true,
            isInGameStore: false,
            isPlaystationStore: true,
            isPlatformRepresentative: true,
            isConsumable: false,
            leadPublisherName: 'BANDAI NAMCO Entertainment America Inc.',
            marketingStories: [],
            compatibilityNotices: [
                {
                    type: 'NO_OF_PLAYERS',
                    value: 1,
                },
                {
                    type: 'NO_OF_NETWORK_PLAYERS_PS_PLUS',
                    value: 6,
                },
                {
                    type: 'DUALSHOCK4_VIBRATION',
                    value: true,
                    targetPlatforms: ['PS4'],
                },
                {
                    type: 'REMOTE_PLAY_SUPPORTED',
                    value: true,
                },
                {
                    type: 'ONLINE_PLAY_MODE',
                    value: 'OPTIONAL',
                },
            ],
            storeFronts: ['PS5', 'PS4', 'WEB_STORE'],
            supportedStoreFronts: ['PS5', 'PS4', 'WEB_STORE'],
            revisionIds: {
                all: 1660806092851,
                self: 1632442325736,
            },
            targetPlatforms: ['PS4'],
            skus: [
                {
                    id: 'UP0700-CUSA03388_00-DARKSOULS3000000-U001',
                    displayPrice: 'R$249,99',
                    price: 24999,
                    eligibilities: [],
                    type: 'STANDARD',
                    name: 'Jogo Completo',
                    entitlements: [
                        {
                            id: 'UP0700-CUSA03388_00-DARKSOULS3000000',
                            name: 'DARK SOULS™ III',
                            applicationType: 'PAID_STANDALONE_FULL_APP',
                            packageType: 'PS4GD',
                            preorderPlaceholderFlag: false,
                            type: 'UNIFIED',
                            subType: 'REGULAR',
                            packages: [
                                {
                                    playablePlatform: 'PS4',
                                    size: 18244304896,
                                },
                            ],
                            featureType: 'FULL_GAME',
                            usageQuantity: 0,
                            usageTime: 0,
                        },
                    ],
                    chargeImmediatelyFlag: false,
                    storeFronts: ['PS5', 'WEB_STORE', 'PS4'],
                    supportedStoreFronts: ['PS5', 'PS4', 'WEB_STORE'],
                },
            ],
            offers: {
                osls: [],
                skuRelevancy: [
                    {
                        skuId: 'UP0700-CUSA03388_00-DARKSOULS3000000-U001',
                        offerAvailability: [],
                    },
                ],
            },
            starRating: {
                total: '24683',
                score: '4.77',
                count: [
                    {
                        score: 1,
                        count: 751,
                    },
                    {
                        score: 2,
                        count: 163,
                    },
                    {
                        score: 3,
                        count: 338,
                    },
                    {
                        score: 4,
                        count: 1483,
                    },
                    {
                        score: 5,
                        count: 21948,
                    },
                ],
            },
            isTrending: false,
            contentTypeId: 1,
            highlights: {
                'product.name': ['', 'DARK', ' ', 'SOULS', '™ III'],
            },
            isEntitledTo: false,
        },
    }

@isFakeAccount I don't know if you care about this, but removing the parameters for language, country, age, and cursor didn't seem to affect my results at all, I still got localized data regardless (as seen above). I don't know if that data was based on my IP or the logged-in account's country. Would need further testing to find out.

The only thing that made any difference in my results was changing pagination.pageSize. Changing it to 50 gave me up to 50 results, changing it higher than that threw an error about the max limit being 50. Thanks for the endpoint and the documentation!

@GusAV did this answer your question? Sorry about the tangent.

Jorrex commented 1 year ago

I'm very much interested in this. Was also looking for a way to search for games and not have to iterate over users their profile and hope to find the corresponding game(s).

I'll follow this request.

TheYuriG commented 1 year ago

I'm very much interested in this. Was also looking for a way to search for games and not have to iterate over users their profile and hope to find the corresponding game(s).

Keep in mind that this is the data you get back and that you can only follow up from this to find the related trophy list using the endpoint for #122, but you won't be able to get the trophies for the game unless you are scanning an account that has synced the game to their profile. In case the trophy list matters for your final objective.

Jorrex commented 1 year ago

I'm very much interested in this. Was also looking for a way to search for games and not have to iterate over users their profile and hope to find the corresponding game(s).

Keep in mind that this is the data you get back and that you can only follow up from this to find the related trophy list using the endpoint for #122, but you won't be able to get the trophies for the game unless you are scanning an account that has synced the game to their profile. In case the trophy list matters for your final objective.

Yes, I'm aware. I'm working on a Discord bot for a PlayStation community. So other than having to iterate over people's profiles and hoping I can find a game to get details for it, just being able to query the API for the game itself would be much more ideal. That's why I'm interested in this feature ;)