liveBook · Manning

Resource

As explained in Grokking Software Architecture

A resource is a web-accessible entity identified by a uniform resource identifier and manipulated through standardized operations.

A resource is a web-accessible thing—such as a user, order, or product—identified by a URL and accessed through standard web operations. Think of a vending machine: each slot is an address, and pressing its button returns the item assigned to that slot. section 6.4.1 section 6.9.1

Designing around resources makes API behavior easier to predict:

  • Use standard verbs such as GET to read, POST to create, and DELETE to remove. section 6.9.1
  • Make each request self-contained: the server should not need to remember session state between requests. section 6.9.1
  • Choose verbs with retry behavior in mind: repeating a GET, PUT, or DELETE leaves the same result, while repeating a POST can create multiple charges. section 6.4.1
Listing 6.1 REST Response
// REST Response: #A
{
  "id": "123",
  "name": "Salt & Vinegar Chips",
  "price": 1.50,
  "calories": 250,
  "ingredients": [ "Potatoes", "Oil", "Salt"... ],
  "manufacturer": { "name": "SnackCorp", "address": "123 Food Lane" }
}

A product resource response shows how one URL can return the whole product record—even when a client only needs its name or price. section 6.4.1

How Grokking Software Architecture covers it

How deep it goes
Defines resources through URLs and standard operations, then illustrates over-fetching and operation retry behavior.
Examples
Uses vending-machine slots, product records, and repeated order requests to illustrate resource access and operation behavior.
What you can do after
Evaluate API operations by their resource, standard verb, and consequences when a request is repeated.
How it connects
Connects resources to REST, URLs, HTTP methods, statelessness, cacheability, and idempotency.

Also explained in

Compare how 3 books explain resource →

Related concepts

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