Just as a basic question in Magento 2. In Magento U tutorials, it says:

In Magento 2 Modules only communicate through API

One module in not aware of the internals of another, so the implementation can change.

Modules can be disabled or deployed on separate servers.

I don't get what it means by "Magento 2 modules only communicate through API" ? If I want to load products, how we are using APIs without knowing?

I need a little bit explanation about interface vs. API interface vs. Web API. Is there any difference ? How?


In this particular statement, API refers to service contracts. It is different than web APIs.

A service contract is a set of PHP interfaces that are defined for a module. A service contract includes data interfaces, which preserve data integrity, and service interfaces, which hide business logic details from service requestors such as controllers, web services, and other modules.

enter image description here

You can find more information regarding service contracts in the official documentation: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/service-contracts/service-contracts.html

On the other hand, here is the official doc for the Web API: http://devdocs.magento.com/guides/v2.0/get-started/bk-get-started-api.html

Finally regarding your question to load products, I reckon you should check that question that highlights the benefits of using service contracts: Magento 2: what are the benefits of using service contracts?

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.