Steam APIで特定のゲームの新着情報を取得する方法

PC上でゲームができるプラットフォーム「Steam」にはAPI(Steam API)が提供されています。

今回は、Steam APIを使って「特定のゲームの新着情報を取得する方法」を書きました。

Steam APIを使って特定のゲームの新着情報を取得する方法

例として、僕が今最高にはまっている「ストリートファイターV」の新着情報を取得します。

ちなみに、新着情報を取得するだけならSteam APIキーは必要ありません。今のところ誰でも取得できますし、もちろんゲームを買っていなくてもOKです(2016/08/17 現在)。

Steam APIキーを取得する方法は以下のページをご参考ください。

というわけで、さっそく~。以下のURLにアクセスすると、json形式でストリートファイターVの新着情報が取得できます。

http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=310950

取得結果(一部)

{
 "appnews": {
  "appid": 310950,
   "newsitems": [
    {
     "gid": "251457560647126425",
     "title": "Kick-o! Street Fighter V Adding Juri On Tuesday",
     "url": "http://store.steampowered.com/news/externalpost/rps/251457560647126425",
     "is_external_url": true,
     "author": "contact@rockpapershotgun.com (Alice O'Connor)",
     "contents": "<p><img src=\"https://www.rockpapershotgun.com/images/16/jul/22sfvjuri.jpg\" title=\"She's a baddie, in case you can't guess.\" /></p>\n<p>This month&#8217;s <a href=\"https://www.rockpapershotgun.com/tag/street-fighter-v/\">Street Fighter V</a> [<a href=\"http://streetfighter.com/\">official site</a>] will launch on Tuesday, July 26th, Capcom have announced. The biggest addition is Juri joining the playable lineup, returning from Super Street Fighter IV. She&#8217;s already appeared in SFV through <a href=\"https://www.rockpapershotgun.com/2016/06/27/street-fighter-v-balrog/\">its Story Mode</a>, released last month, but now everyone will get to kick faces as the Taekwondo expert (cheeky modders have enabled her earlier, mind). Here, this trailer shows some of her moves:</p>\n<p> &#8230; [<a href=\"https://www.rockpapershotgun.com/2016/07/22/street-fighter-v-july-update-juri/\">visit site to read more</a>]</p>\n",
     "feedlabel": "Rock, Paper, Shotgun",
     "date": 1469216360,
     "feedname": "rps"
    },
    {
     "gid": "250329347090723251",
     "title": "SFV “A Shadow Falls” and Two New Characters Release",
...

URLにはストリートファイターVのappid「310950」のみ指定していますが、他にも指定できるクエリパラメーターがあります。

以下にまとめましたので、ご参考ください。

指定できるクエリパラメーター

appid ゲームのアプリケーションID
count 表示する新着情報の件数
maxlength 新着情報1記事あたりの文字数
format 取得する形式(json,xml,vdf デフォルト:json)

その他、詳しくは「Steam Web API ドキュメント」がありますので、そちらをご参考ください。

著者:bouya Imamura