/schema/table/key
So: //www.example.com/calendar/events/123
To address many records, like all that belong to Bob, use the query string instead of purely the path: //www.example.com/calendar/events/?user=bobBut it makes it a bit weird to do HATEOAS; you _could_ do `GET Bob => {events: "calendar/events/?user=bob"}` -- but then you're hyperlinking to a search and not a resource.
It also tells less of a narrative in the structure; `user=bob` is just another filter that you can use to apply to the events set. But we get a chance to describe the shape of the data a bit more if we choose to declare an intermediate resource (/users/) and attach some links to it (=>/users/bob/events).
Now, if there are ten ways that you need to slice your `events` set, and ?user=bob is but one of them, then scoping a sub-resource /users/events/ isn't that useful/descriptive.
As an aside, I think this is where HATEOAS is nice; it makes it very easy to navigate an API as a developer, see what actions are possible at every node, and hopefully learn the intent of the author of the API without having to chew through a set of API documentation. Django Rest Framework's API browser is a great example here.
//calendar.googleapis.com/users/-/events/123But it doesn't cover the case I'm referring to; in their example you MUST return the fully-qualified URL:
> shelves/shelf713/books/book8141, not shelves/-/books/book8141
This precludes there being multiple shelves with the same book (sensible in their example, since a book has only one shelf, but not in the example above).
I think this pattern is unambiguously sensible when the child objects are strictly scoped under the parent.
But it's less clear how to represent resources that are shared between multiple parents; for example, what if event 123 can be referenced under another user's API resource as well? If we permit `//calendar.googleapis.com/users/bob/events/123`, now we have multiple URLs referring to the same object, and things can get quite tricky in the implementation.
Django Rest Framework strongly discourages (and makes it quite hard to implement) nested resources, FWIW.
I've found that a policy of only permitting one level of nesting seems to be a good balance for shared objects, e.g.
`//calendar.googleapis.com/users/john smith/events/` returns:
``` [ { url: "/events/123"}, ... ] ```
Interested to know how others have solved this problem.
[1]: https://cloud.google.com/apis/design/resource_names