API Design Guidance: Singletons
Blog post from Tyk
Singleton resources in API design represent a single instance of a resource, as opposed to a collection, and are particularly useful when a collection is unnecessary. This design pattern can simplify APIs by providing a direct interaction point, such as a user's unique profile or preferences, and avoids confusion associated with trying to apply CRUD operations to non-collection resources. Singleton resources allow for straightforward API shortcuts, like GET /me for user identification, and offer flexibility by using HTTP methods like PUT and POST to manage their lifecycle, often adhering to an upsert pattern. However, it is crucial to assess whether a resource might require full CRUD support in the future, as transitioning from a singleton to a CRUD-based resource can result in breaking changes.