12 Singleton sub-resources

This chapter covers

  • What singleton sub-resources are
  • Why and when we should split data off into a singleton sub-resource
  • How standard methods interact with sub-resources
  • Where singleton sub-resources live in the resource hierarchy

In this pattern, we’ll explore a way of structuring related but independent data by moving it from a set of properties on a resource to a singleton child of that resource. This pattern handles scenarios where a specific collection of data might change independently of the parent, have different security requirements, or simply might be too large to store directly as part of the resource.

12.1 Motivation

When building APIs, we sometimes have situations where there are components of resources ...

Get API Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.