Creating custom Web APIs
Magento comes with a solid number of API methods that we can call. However, sometimes this is not enough, as our business needs dictate additional logic, and we need to be able to add our own methods to the Web API.
The best part of creating our own API's is that we do not have to be concerned about making them REST or SOAP. Magento abstracts this so that our API methods are automatically available for REST and for SOAP calls.
Adding new API's conceptually evolves around two things: defining business logic through various classes, and exposing it via the webapi.xml
file. However, as we will soon see, there is a lot of boilerplate to it.
Let's create a miniature module called Foggyline_Slider
, on which we will demonstrate ...
Get Magento 2 Developer's 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.