title: How can I expose statistics about resources through a RESTful API?
body: <p>I'm building an API for my web app and have got as far as exposing all the resources my app uses, e.g. <code>/users</code>, <code>/roles</code>, <code>/posts</code> etc with no problem.</p>
  
  <p><strong>I'm now stuck on how to expose statistics about some of these resources in a RESTful way.</strong> It doesn't seem right to have a <code>statistics</code> resource, as <code>GET /statistics/1</code> could be anything, and the results will likely change each request, as the stats are real-time, so it will not be cacheable.</p>
  
  <p>Background:</p>
  
  <p>For each of the <code>/users</code> in the system, the app periodically queries Steam's API for the <code>/games</code> they are playing, and the <code>/servers</code> they are playing it on, and stores this information along with a timestamp in the <code>/states</code> resource.</p>
  
  <p>This information is aggregated to show a tally of the most popular games and servers on the <code>/statistics/games/current-usage</code> and <code>statistics/servers/current-usage</code> standard HTML pages. Illustrative screenshots: <a href="http://zeropingheroes.co.uk/wp-content/gallery/lanager/servers.png" rel="noreferrer">servers</a>, <a href="http://zeropingheroes.co.uk/wp-content/gallery/lanager/games.png" rel="noreferrer">games</a> (taken at different times).</p>
  
  <p>EDIT: Sample data for the basic resources</p>
  
  <pre><code>"state": {
      "id": 292002,
      "user_id": 135,
      "game_id": 24663,
      "server_id": 135,
      "created_at":"2014-06-22 21:12:03"
  },
  "user": {
      "id": 112,
      "username": "ilumos",
      "steam_id_64": "76561197970613738"
  },
  "server": {
      "id": 135,
      "application_id": 24663,
      "name": null,
      "address": "192.168.241.65",
      "port": "0"
  },
  "game": {
      "id": 24663,
      "name": "DEFCON",
      "steam_app_id": 1520
  }
  </code></pre>
  
  <p><strong>EDIT 2: Does REST permit endpoints that use a timestamp as the resource identifier?</strong> e.g:</p>
  
  <p><code>GET /statistics/1403681498/games</code> to get a response like this:</p>
  
  <pre><code>[
      "game": {
          "id": 123,
          "name": "DEFCON",
          "users": [
              {
                  "id": 7654,
                  "username": "daryl",
                  "server": {
                      "id": 127,
                      "ip": "123.123.123.123",
                      "port": "27960"
                  }
              },
              {
                  "id": 135,
                  "username": "ilumos"
              },
          ]
      }
  ]
  </code></pre>