My applications deals a lot with statistics, analysis and derived data sets in general.
Some of this data is calculated on the fly when it is requested, some is calculated
in batch at a regular interval.
The data returned by these may be constantly changing (like, minute to minute),
and there is no way to refer to the returned objects via a unique id, because they
aren’t stored in such a way that they can looked up via that unique id. It is
though compulsory in the spec to include a unique id. Of course, I can include a
unique id (i.e some random number), but surely this only confuses the client
as perhaps now they think they can use this id to later refer to this resource!
Another issue I’ve run into recently, is that I want to force a recalculation
of a user’s statistics (because the statistics are not calculated on the fly, they
are precalculated and put into a DB table). I was trying to think of a creative
way to do this that was still sane, and I came up with doing a ‘PATCH /users/123/statistics/’.
Because I want to indicate to the server that I want that particular resource updated. Of course
the client does not set the data, the server calculates it, but yet I still have to pass a resource object
complete with id (according to the spec). IMHO including that data would be extremely
confusing (i.e ‘why are you sending data that is not actually part of the updated resource?’)
I’ve just been making it up as I go along, and abandoning parts of the spec that I feel
don’t make sense to my application, and including those that I feel do.
Am I doing it wrong?