Free API for accessing Crypto Exchange Rates | Free Crypto API

24 March 2023 421 Reading time: 1 minute

If you are looking for a free API to access real-time exchange rate information for Bitcoin and other cryptocurrencies, you've come to the right place.

To access real-time exchange rate information for Bitcoin, you can use APIs provided by various cryptocurrency exchanges. These APIs allow you to access up-to-date price information for Bitcoin and other cryptocurrencies.

For example, popular cryptocurrency exchange Coinbase offers an API that can be used with PHP. Through this API, you can access real-time exchange rate information for Bitcoin and other cryptocurrencies.

To get started, you'll need to sign up for the Coinbase API and then integrate the API into your PHP code using your API keys.

The following example code shows you how to use the Coinbase API to access real-time exchange rate information for Bitcoin:


<?php
// Coinbase API URL
$url = "https://api.coinbase.com/v2/exchange-rates?currency=BTC";
// API request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// API response
$data = json_decode($response, true);
$bitcoin_price = $data['data']['rates']['USD'];
// print Bitcoin price
echo "Bitcoin price: " . $bitcoin_price . " USD";
?>

This code accesses real-time exchange rate information for Bitcoin using the Coinbase API and prints the result to the screen. This example retrieves the price of Bitcoin in USD, but you can use the API to retrieve exchange rate information for different currencies as well.

Similar articles