DEV Community

Cover image for Getting current BitClout Price using BitClout API
Aditya Chaudhary👨‍💻
Aditya Chaudhary👨‍💻

Posted on

Getting current BitClout Price using BitClout API

Getting the BitClout price is really a must needed data since calculation of coin price, market cap, Total USD locked etc. is dependent on the current BitClout price.

The workaround to get the current BitClout price in USD is really easy! All you need is to do a GET request to https://api.bitclout.com/get-exchange-rate to get the price of BitClout in BitCoin and then make a GET request to https://api.coindesk.com/v1/bpi/currentprice.json to get the current price of BitCoin in USD!

You are all set now!
Just multiply the Bitcoin price in USD with BitClout price in Bitcoin and you have the current price of BitClout!

Here is a working code in python.

import requests
def getBitCloutPrice():  # return BitClout price in USD
  response = requests.get("https://api.coindesk.com/v1/bpi/currentprice.json")
  data = response.json()
  bitcoin_price = float(
  data["bpi"]["USD"]["rate"].replace(",", ""))  # Bitcoin price in USD

  r = requests.get("https://api.bitclout.com/get-exchange-rate")
  bitclout_in_bitcoin = (
            int(r.json()["SatoshisPerBitCloutExchangeRate"]) * 0.00000001
        )  # Bitclout price in Bitcoin
  bitclout_price = bitcoin_price * bitclout_in_bitcoin  # Bitclout price in USD

  return bitclout_price

if __name__ == "__main__":
  print(getBitCloutPrice())
Enter fullscreen mode Exit fullscreen mode

If you want to learn more about the price of BitClout and how it is actually calculated check out Tijn's Formula

If you like the article don't forget to let us know in the comments or maybe give a shout to DevsClout ? You can also join DevsClout discord server to chat with more devs who are building awesome projects on BitClout!
We would love to hear back from you!

Top comments (0)