In D7 we used drupal_http_request . to retrieve remote data from other sites and then manipulated in in drupal, well there is no more of that function, we are using HTTP Guzzle from Symfony in drupal8 https://www.drupal.org/node/1862446
So to do that we can try this simple example:
$url = "https://api.coinmarketcap.com/v2/ticker/";
try {
$response = \Drupal::httpClient()->get($url, array('headers' => array('Accept' => 'text/plain')));
$data = json_decode((string) $response->getBody());
if (empty($data)) {
return FALSE;
}
}
catch (RequestException $e) {
return FALSE;
}
print_r($data);
so we have this API where we get some JSON data, we call the method, add parametars and then json_decode response, in the end we print it out so we can see what we got.