Best Magento API method for Apps


What’s the best Magento API method to communicate with your apps Android, iOS and SPA (Single Page Application)? Normally the options are SOAP, REST, create a custom module with JSON response or Magento 1 default mobile apps using XML Connection. Then the workflow necessary is to use authentication, to be fast to data fetch and fast to develop.

My response is REST API, reasons:

  • It is much easier to implement than SOAP as PHP notoriously does not always follow the same standards as - for instance - Microsoft products do. Also, dealing with SOAP implies dealing with XML, namespaces, and WSDL. Of course, it will work if done properly, but the cost of developing this for iOS would be greater.

  • SOAP is based on XML, and requires downloading (and perhaps caching) of a service definition file (also XML), and XML is mostly more verbose and therefore more bandwidth-consuming than REST data encoding, not to mention memory usage for parsing (if you use DOM parsers), decoding and in-memory object-based tree-like document representation. REST, at the other hand, is much less bandwidth and memory consumptive, which makes it more suitable for mobile devices.

  • JSON would be great, but that would require for you to implement a whole new API interface at Magento side, which may have consequences with regards to Magento security as well, not to mention the complexity of it overall. I would suggest using the native Magento REST-based API, and eventually, a plugin with custom services. This would be a more reliable (REST API is supported by Magento, it’s tested by a wider range of customers, and Magento provides some updates - as security updates - for it along with releases) and cost-effective solution.

If you have a new perspective about, please tell us more into the comments.