DEV Community

Cover image for Get BAT price with Python

Posted on

Get BAT price with Python

BAT (Basic Attention Token) is a decentralized ad exchange platform built on the Ethereum platform.

The token aims to correctly price user attention within the platform. Advertisers pay BAT to website publishers for the attention of users.

The BAT ecosystem includes Brave, an open-source, privacy-centered browser designed to block trackers and malware. It leverages blockchain technology to anonymously and track user attention securely and rewards publishers accordingly.

Earning BAT

At this point in time, you can only collect BAT, but there doesn't seem to be a way to withdraw it to other crypto-currency. But you could collect BATs and wait for withdraw support in the future.

Edit: You can now collect BAT tokens, withdraw BAT


BAT can be exchanged for other crypto-currencies or you can exchange to another btc and then to fiat currency.

You can get the current price of BAT with Python:

import requests
import json
from forex_python.converter import CurrencyRates
import os

c = CurrencyRates()
rate = c.get_rate('USD', 'EUR') 

basic_attention_token_api_url = ''
response = requests.get(basic_attention_token_api_url)
response_json = response.json()

for coin in response.json():
    price = coin.get("price_usd", "U$S Price not provided")
    coin_price = float(("{0:.2f}").format(float(price)))
    print("$ " + str(coin_price))
    coin_price_eur = float(("{0:.2f}").format(float(price)*rate))   
    print("E " + str(coin_price_eur))


Read more:

Top comments (0)