DEV Community

Cary Reams
Cary Reams

Posted on

RESTful and Summary Resource Paths

I'm a big fan of RESTful approach to defining paths and accessing resources. The struggle today is how to approach what I refer to as "summary" resources.

For example, if the desire were to provide the current standings for a sports league - teams, wins, losses, games-behind, winning-percentage - how would that path be defined ?

  • /sportsleague/standings ?
  • /sportsleague/standing ?

What if there are multiple "formats" of similar information ?

What if the first were standings within a conference, but the second format were playoff standings (see USA's National Basketball Association) that completely ignore individual conferences (subsets).

  • /sportsleague/standing(s?) and /sportsleague/playoffstanding(s?) ?
  • /sportsleague/standing/conference and /sportsleague/standing/playoff

For added complexity, consider a third report that considers additional at-large playoff spots (see USA's Major League Baseball or National Football League's "wildcard" standings concept)? The games behind metric still means the same thing, but its been adjusted to consider who "leads" the wild card chase. Rather than meaning "games out of first place," it comes to mean "games out of the playoffs" and is therefore based on the "last wildcard team" not the "first wildcard team." That's all a long way of saying the calculation is different, but the presentation structure is the same.

  • (from above) ... and /sportsleague/playoffstandingwildcard(s?) ?
  • (from above) ... and /sportsleague/standing/wildcard ?

More generally, if this is just one of a number of summary reports, would we toss all reports into a category and nest specifics within the reports category ?

  • /sportsleague/report/standing/conference
  • /sportsleague/report/standing/playoff
  • /sportsleague/report/player/17/career

But in this case, the application of a "report resource" would seem to be non-beneficial.

  • /sportsleague/standing/conference
  • /sportsleague/standing/playoff
  • /sportsleague/player/17/career

The real context for my question revolves around attempting to define RESTful paths to many different statistical reports which all use the same core data, but perform subtly different analysis for consumption by the user.

For example, we have (at least) three different reports which compose a list of people and their top five talents into a matrix sorted by various (non-trivial) criteria - the different criteria are the source of the different reports. I'm having difficulty defining the paths to access the data.

Looking forward to reading your suggestions and answering any clarifying questions. And if I've started off on the wrong foot conceptually (it happens), please point me off in another direction that has something better to offer.

Thanks,
Cary

Top comments (2)

Collapse
 
mjb2kmn profile image
MN Mark

Is the sports standings only an illustrative example?

Collapse
 
carywreams profile image
Cary Reams

yes - just meant to indicate the same model's data may be fashioned into different "reports." I'm struggling with how to name reports as resources in a RESTful manner.