How do I get a hash for a picture form a Steam Game?

笑着哭i 提交于 2020-08-26 07:17:47

问题


I want to get a image/logo/icon from steam games with the steam web api, but the problem with the api is, they ask for a hash in the url. Where can I get the hash?

Steam api link: http://media.steampowered.com/steamcommunity/public/images/apps/{appid}/{hash}.jpg

Example: http://media.steampowered.com/steamcommunity/public/images/apps/440/07385eb55b5ba974aebbe74d3c99626bda7920b8.jpg


回答1:


Most of their official API endpoints, such as GetOwnedGames documented here , to get owned games for an user, return application details when setting the include_appinfo query parameter.

The returned details then include the hashes you were looking for, as img_icon_url and img_logo_url in a game's object.

As written in their docs,

these are the filenames of various images for the game. To construct the URL to the image, use this format:

http://media.steampowered.com/steamcommunity/public/images/apps/{appid}/{hash}.jpg

Here's an example of a request http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=YOUR_API_KEY&steamid=YOUR_STEAM_ID&include_appinfo=true&format=json

And a game's result key from this very request.

         {
            "appid": 400,
            "name": "Portal",
            ...
            "img_icon_url": "cfa928ab4119dd137e50d728e8fe703e4e970aff",
            "img_logo_url": "4184d4c0d915bd3a45210667f7b25361352acd8f",
            ...
        },

So, for the portal logo the resulting URL would be http://media.steampowered.com/steamcommunity/public/images/apps/400/4184d4c0d915bd3a45210667f7b25361352acd8f.jpg




回答2:


Replace 440 with any other valid ID of game/app. That's what you need.

https://steamcdn-a.akamaihd.net/steam/apps/440/header.jpg



来源:https://stackoverflow.com/questions/53963328/how-do-i-get-a-hash-for-a-picture-form-a-steam-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!