Resource layout organizes an API’s resources, fields, and relationships. It determines which concepts become resources, how they associate, and whether clients interact with them through separate collections or nested hierarchies. section 4.1
Use the chat-room relationship diagram to see how one ChatRoom resource can relate to many User resources. section 4.1
Choose relationships deliberately:
- Create a relationship only when it provides important, fundamental API behavior; large fan-out relationships can make one change affect millions of records. section 4.2.1
- Make a concept a separate resource when it needs independent, atomic interaction; otherwise, inline it as a data type. section 4.5
- Avoid overly deep hierarchies because they become difficult to understand and manage. section 4.5
- Treat frequent custom methods as a warning that resources or relationships may be poorly chosen rather than using methods as design duct tape. section 9.4
Centralized operations
For long-running operations, place Operation resources in a top-level collection such as /operations/1 rather than scattering them beneath individual resources. A centralized collection supports discovery across the system and handles operations that are not centered on one resource. section 10.3.2
Reconsider a parent-child relationship when copying, moving, or renaming resources becomes difficult. Such problems may indicate poorly chosen identifiers or a relationship that should have been referential instead. section 17.4
