CoinLayer

CoinLayer

Cryptocurrency

Real-time Crypto Currency Exchange Rates JSON Rest API

Visit API

📚 Documentation & Examples

Everything you need to integrate with CoinLayer

🚀 Quick Start Examples

CoinLayer Javascript Examplejavascript
// CoinLayer API Example
const response = await fetch('https://coinlayer.com', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Introduction to Coinlayer API

Coinlayer is a public API that provides real-time and historical cryptocurrency exchange rates. It supports over 385 cryptocurrencies and provides data in over 25 fiat currencies. Coinlayer offers a free plan and also provides paid plans with more features.

How to use Coinlayer API

  1. Signup for a free account at https://coinlayer.com.
  2. Once you are logged in to your account, you can access the API key.
  3. Coinlayer API supports HTTPS requests. Use the endpoint https://api.coinlayer.com to make the requests.

API examples

Get real-time exchange rates

This example code shows how to get real-time exchange rates for Bitcoin, Ethereum, and Litecoin in USD using JavaScript.

const API_KEY = 'YOUR_API_KEY';
const CRYPTOCURRENCIES = 'BTC,ETH,LTC';
const CURRENCY = 'USD';

fetch(`https://api.coinlayer.com/live?access_key=${API_KEY}&symbols=${CRYPTOCURRENCIES}&target=${CURRENCY}`)
  .then(response => response.json())
  .then(data => console.log(data.rates));

Get historical exchange rates

This example code shows how to get historical exchange rates for Bitcoin, Ethereum, and Litecoin in USD for a specific date using JavaScript.

const API_KEY = 'YOUR_API_KEY';
const CRYPTOCURRENCIES = 'BTC,ETH,LTC';
const CURRENCY = 'USD';
// Date should be in YYYY-MM-DD format
const DATE = '2021-10-21';

fetch(`https://api.coinlayer.com/${DATE}?access_key=${API_KEY}&symbols=${CRYPTOCURRENCIES}&target=${CURRENCY}`)
  .then(response => response.json())
  .then(data => console.log(data.rates));

Convert one cryptocurrency to another

This example code shows how to convert 1 Bitcoin (BTC) to 10 Ethereum (ETH) using JavaScript.

const API_KEY = 'YOUR_API_KEY';
const FROM_CURRENCY = 'BTC';
const TO_CURRENCY = 'ETH';
const AMOUNT = 1;

fetch(`https://api.coinlayer.com/convert?access_key=${API_KEY}&from=${FROM_CURRENCY}&to=${TO_CURRENCY}&amount=${AMOUNT}`)
  .then(response => response.json())
  .then(data => console.log(`1 ${FROM_CURRENCY} is equal to ${data.result} ${TO_CURRENCY}`));

Conclusion

Coinlayer API makes it easy to access real-time and historical cryptocurrency exchange rates. With the help of these examples, you can easily integrate Coinlayer API with your JavaScript application.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jul 24Jul 26Jul 28Jul 30Aug 1Aug 3Aug 5Aug 7Aug 9Aug 11Aug 13Aug 15Aug 17Aug 19Aug 2204008001440Minutes
Online
Offline

Related APIs in Cryptocurrency