When i look at magento 2 core, in some modules API directory is present and in some modules there is no API directory.

API Directory is used for implementing Web services(SOAP,REST) or it has other purpose too??


Api directory have repositories.

It Contains set of code that third-party developers can call, implement, or build as a plug-in. Magento guarantees that this code will not change in subsequent releases without a major version change.
Public interfaces for a module are marked with @api annotation.

In general, the purpose of a repository is to hide the storage related logic. A client of a repository should not care whether the returned entity is held in memory, in an array, is retrieved from a MySQL database, fetched from a remote API or from a file.
Magento 2 repository methods can easily be exposed as API resources, making them valuable for integrations with third party systems or headless Magento instances.

UseFul Links :
http://devdocs.magento.com/guides/v2.2/extension-dev-guide/api-concepts.html http://vinaikopp.com/2017/02/18/magento2_repositories_interfaces_and_webapi/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.