I create an API for my web application and get it until I reveal all the resources that my application uses, for example. /users , /roles , /posts , etc. no problem.
I am now fixated on how to expose statistics on some of these resources in a RESTful way. It does not look like the statistics resource, since GET /statistics/1 could be everything, and the results are likely to change every request, since the statistics are in real time, so it will not be cached.
Background:
For each of the /users on the system, the application periodically requests the Steam API for the /games they play and the /servers in which they play, and saves this information along with the timestamp in the /states resource.
This information is aggregated to show the number of the most popular games and servers in the standard HTML pages /statistics/games/current-usage and statistics/servers/current-usage . Illustrative screenshots: servers , games (taken at different times).
EDIT: Sample Data for Core Resources
"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 }
EDIT 2: Does REST allow endpoints to use a timestamp as a resource identifier? eg:
GET /statistics/1403681498/games to get an answer like this:
[ "game": { "id": 123, "name": "DEFCON", "users": [ { "id": 7654, "username": "daryl", "server": { "id": 127, "ip": "123.123.123.123", "port": "27960" } }, { "id": 135, "username": "ilumos" }, ] } ]