Providing links for large sets of individual resources


The examples on are mostly focused on links to resources when there is a small number of them, like the 1 author of an article, or the 5-10 comments on that article. It works to have a relationships object with links to comments when there aren’t that many comments. If there are many comments then we can provide paginated links for fetching them in small groups.

Sometimes that approach doesn’t quite fit, because we have a large number of items on the server, but we do not want to support pagination over the set or filtering it. The only intended interface is for clients to fetch a single one of the items directly using a known ID.

For example, suppose we have an endpoint to return a specific user, /users/{user_id}.

json:api does not allow URI templates as links. If URI templates were allowed then I might include a link like /users/{user_id}

Providing an /users index link would be one solution but it is undesirable for the following reasons:

  • Returning the full set of users all at once is not feasible because there are too many users, so we would need to protect against that.
  • In the pagination approach, we would need to build support for pagination and there is no other demand for that.
  • We could use a filter approach, /users?filter[user]=123, but we still don’t have a clear way to provide the filter template, and that is just an indirect way to fetch the single desired user.

What strategies do people use to provide links to individual resources when the number of such links is large?