Using existing web APIs

The CRUD and search models of web APIs are implemented through a set of *RepositoryInterface interfaces, found in the <VendorName>/<ModuleName>/Api/<EntityName>RepositoryInterface.php files.

The majority of these repository interfaces define a specific set of common methods:

  • save
  • get
  • getById
  • getList
  • delete
  • deleteById

The data type that flows through these methods follows a certain pattern, where each entity passing through an API has a data interface defined in a <VendorName>/<ModuleName>/Api/Data/<EntityName>Interface.php file.

Let's take a closer look at <MAGENTO_DIR>/module-cms/Api/BlockRepositoryInterface.php:

interface BlockRepositoryInterface{    public function save( \Magento\Cms\Api\Data\BlockInterface $block ...

Get Magento 2 Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.