title: Trying to get property 'price_change_percentage_24h' of non-object
body: <p>I'm trying to work with an API from coingecko and lets say get the 24 hour percentage value for BTC as a PHP variable on page load. This is the api <a href="https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&amp;ids=bitcoin" rel="nofollow noreferrer">https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&amp;ids=bitcoin</a>.</p>
  <p>my code:</p>
  <pre><code>$jsonArrayResponse = null;
    try{
      $cURLConnection = curl_init();
  
      curl_setopt($cURLConnection, CURLOPT_URL, 'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&amp;ids=bitcoin');
      curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
  
      $res = curl_exec($cURLConnection);
      curl_close($cURLConnection);
  
      $jsonArrayResponse = json_decode($res);
    }catch(Exception $ex){
        echo &quot;Api Error: &quot;.$ex-&gt;getMessage();
    }
    $btcpricechange = $jsonArrayResponse-&gt;price_change_percentage_24h;
  </code></pre>
  <p>now the problem is i'm getting this error &quot;Trying to get property 'price_change_percentage_24h' of non-object&quot;
  i'm currently using my above code with a coinbase api as well as a cryptocompare api and it works fine. while i have little understanding of how to handle api calls, i don't think i'm doing something wrong.. please help</p>