Architecture:MediaWiki/API layer

From mediawiki.org

The API layer is responsible for interacting with client software, typically over HTTP. This primarily means interpreting and validating requests from the client, acting on the request by changing state, and responding by sending back data.

Encoding and decoding domain "nouns" (as defined in the entity layer) is an essential part of the API layer's responsibility. However, it should be noted that this encoding should be considered separate from the one used for persistence in the storage layer.

Status:
As per August 2020, a lot of logic that belongs into the API layer is entangled with behavior layer and storage layer logic, especially in API modules. As code in the API layer is refactored to reduce coupling, more code will be factored out and moved to the behavior and storage layers.

Constraints:
Code in the API layer should not make use of code in layers above it; in particular, it should not make use of code from the user interface layer.

Dependencies:
Code in the API layer may depend on code in layers below it, such as the behavior layer or the persistence layer. In particular, it will typically make use of commands and data access objects.

Typical patterns:
A typical pattern in the API layer is API modules.

Example:
Examples of API layer code are the CompareHandler and ApiQueryContributors classes.