liveBook · Manning

HTTP GET

As explained in API Design Patterns

A GET method is a standard API method that retrieves the data stored for one identified resource without altering it.

HTTP GET retrieves the data stored for one identified resource. It accepts the resource identifier as its only required input, performs a key-value lookup, and should be idempotent and free of noticeable side effects. section 7.3.3

Listing 7.1 An example of the standard get method
abstract class ChatRoomApi {
  @get("/{id=chatRooms/*}")                          #1
  GetChatRoom(req: GetChatRoomRequest): ChatRoom;    #2
}
interface GetChatRoomRequest {
  id: string;
}

A ChatRoom API maps GET /{id=chatRooms/*} to GetChatRoom, whose request contains the resource identifier. section 7.3.3

Apply these design rules:

  • Return the complete resource by default when partial retrieval through a field mask is supported. section 8.3.4
  • Exclude exceptionally large or expensive fields from the default only when necessary, and document that explicit requesting is required. section 8.3.4
  • Return a soft-deleted resource normally when its identifier is supplied; do not treat that lookup as a request to hide it. section 25.3.2

How API Design Patterns covers it

How deep it goes
Explains identifier lookup, idempotence, field-mask defaults, costly-field exceptions, and soft-deletion behavior, while deferring revisions.
Examples
Demonstrates GetChatRoom with a chat-room identifier and discusses retrieval of soft-deleted resources.
What it assumes
Assumes understanding of resources and identifiers while teaching the standard retrieval contract from first principles.
What you can do after
Build it from scratch as an idempotent retrieval method that returns one identified resource without noticeable side effects.
How it connects
Connects resource identifiers with field masks, singleton sub-resources, soft deletion, and standard update and list methods.

Also explained in

Compare how 14 books explain HTTP GET →

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.