liveBook · Manning

Resource

As explained in API Design Patterns

An API resource is a named conceptual entity that the API stores, exposes, or allows clients to manipulate.

A resource is a named conceptual entity that an API stores, exposes, or lets clients manipulate. Resource-oriented design standardizes the things an API manages and applies familiar actions across them, reducing the need to memorize many subtly different methods. section 1.3 section 1.5

Use resources deliberately rather than turning every data type into an independently managed object:

  • Pair resources with standard operations such as create, get, list, update, and delete when those operations make sense. section 1.3
  • Keep tightly coupled concepts inline when clients do not need to address them independently. An image annotation can contain a bounding box and notes without making each one a full resource. section 4.3.1
  • Treat collections and individual resources differently: list or create against a collection, and get, update, or delete an individual resource. section 9.3.2

Flight reservations as a resource

Instead of exposing unrelated methods such as ScheduleFlight(), ShowAllBookings(), CancelReservation(), and RescheduleFlight(), model FlightReservation as a resource and apply consistent operations: CreateFlightReservation(), GetFlightReservation(), ListFlightReservations(), DeleteFlightReservation(), and UpdateFlightReservation(). section 1.3

How API Design Patterns covers it

How deep it goes
Defines resources, maps them to standard lifecycle methods, and explains scope decisions without detailing implementation internals.
Examples
Uses flight reservations, image annotations, bounding boxes, notes, messages, books, authors, and change-log entries.
What you can do after
Designs resource-oriented APIs with consistent operations, appropriate scope, and clear collection-versus-resource targets.
How it connects
Connects resource-oriented APIs with standard methods, collections, relationships, and RPC-style APIs.

Also explained in

Compare how 3 books explain resource →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.