I want to call a 3rd party REST API within Magento 2. Is there any class to handle the HTTP requests and responses for that?


Thanks for the suggestions. I found that magento is using the Zend HTTP client so i will stick with that at the moment. An example can be found in the DHL module


The link above is outdated, but the module can be found here and more specifically here: The Usage of the Zend-Client within Magento.


If there is no need in Authentication, just use curl (\Magento\Framework\HTTP\Adapter\Curl). If OAuth have to be used, take a look at implementation of web API functional tests framework, which relies on 3rd party library, particularly at \Magento\TestFramework\TestCase\Webapi\Adapter\Rest::call. You will have to implement something similar in custom module.


I would recommend Guzzle. Its not Magento specific, but should work nicely in Magento 2.

Guzzle is my goto to consume a REST API in PHP.


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.