liveBook · Manning

Contract

As explained in The Art of Code

A public API is an externally accessible software interface whose operations and behavior are exposed for use by other systems or clients.

An API is a public software interface and a durable contract between its provider and the systems or clients that depend on it. Its documentation must make operations, constraints, assumptions, and expected behavior understandable. section 9.4.1

A durable API contract commonly specifies:

  • Public operations, parameters, input and output formats, and error responses. section 9.4.1
  • Limits such as rate limits, response sizes, pagination, performance expectations, and required configuration. section 9.4.1
  • Authentication, access control, versioning, and deprecation policies. section 9.4.1
  • Only the smallest necessary public surface, with implementation details hidden behind clear response models. section 9.4.1 section 9.5

Avoid leaking the data model

Returning database entities directly from a REST API exposes internal structure, couples clients to the database schema, and can disclose private information. A separate response model reduces that exposure and preserves freedom to change internals. section 9.4.1 section 9.5

How The Art of Code covers it

How deep it goes
Details contract contents and durability risks, but stops short of implementation-level API construction.
Examples
Uses OpenAPI specifications, Javadoc, written contracts, and the contrast between exposed database entities and separate response models.
What it assumes
Assumes familiarity with software systems, clients, data formats, authentication, and versioning terminology.
What you can do after
Build it from scratch by defining a narrow, documented interface that hides internals and communicates lifecycle expectations.
How it connects
Connects public APIs with encapsulation, REST, response models, versioning, deprecation, authentication, and backward compatibility.

Also explained in

Compare how 44 books explain contract →

Related concepts

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