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 create (POST)
, update (PUT)
, delete (DELETE)
, and list (GET)
method calls.
Create a module registration file, app/code/Foggyline/Slider/registration.php
, with content (partial) as follows:
\Magento\Framework\Component\ComponentRegistrar...