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
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.