liveBook · Manning

Api call

As explained in The Design of Web APIs, Second Edition

An API call is a request made by a client to invoke an API operation or retrieve API data.

An API call is a consumer’s request to perform an operation or retrieve data. In a web API, the consumer sends an HTTP request describing the action and any needed input. The server returns an HTTP response indicating the result and, when appropriate, the resulting data. section 1.1.2

Search a product catalog

A mobile application can send GET /products?type=BD to find Blu-ray products. GET expresses the search action, /products identifies the catalog, and type=BD supplies a filter. A 200 OK response indicates success; its body contains the matching products. section 4.1.1

To design a call, map the operation’s parts to HTTP:

  • Choose a path for the resource and an HTTP method for the action. section 4.1.2
  • Place input data in an appropriate request location, such as query parameters for search filters. section 4.1.2
  • Choose response status codes for outcomes and a location, such as the body, for output data. Model the detailed input and output fields separately. section 4.1.2

A call also has a cost within an operation flow: avoid repeating a read or search call when the same operation with the same parameters would retrieve data already available. For example, a money-transfer flow can list eligible accounts once and reuse that result for both source and destination selection. This changes the flow, not the operation’s design. section 10.3.3

How The Design of Web APIs, Second Edition covers it

How deep it goes
Works through paths, methods, input locations, status codes, and output locations; defers detailed data-field modeling.
Examples
Uses a filtered product search and a money-transfer flow that reuses an account-list result.
What it assumes
Assumes identified resources, actions, inputs, and outputs while introducing how to express them in HTTP.
What you can do after
Practice/perform the mapping of an operation to an HTTP call and identify redundant reads in a flow.
How it connects
Links API calls to resources, HTTP methods, query parameters, status codes, and operation flows.

Also explained in

Compare how 3 books explain api call →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.