If you want to create Bitcoin wallet addresses, Bitcoin addresses, or any other data in Bitcoin blockchain, you can use Python library “Blockchain.info API.”
The Blockchain.info Python Library provides you with the most comprehensive suite of APIs to access your Bitcoin wallet information. You will be able to get information about your balance, transaction history, address book, transactions, and much more. This library comes packaged with everything you need to get started. Simply import the library and you’ll be good to go!
The following are the steps to install the blockchain Python library:
- Open the command-line program on your computer.
- Run the pip install blockchain command to install the blockchain library
Blockchain.info has the most accurate live Bitcoin exchange rates available anywhere on the web. This Bitcoin information site makes it easy to view the current price of Bitcoin, the best exchange rates, live news updates, and other market data.
Here are the steps:
First, import the exchange rates classes from the blockchain library
#!/usr/bin/env python
# import blockchain library
from blockchain import exchange rates
Currency exchange rates define a get_ticker method, which returns the exchange rates data in a dictionary object. Call this method and save the resulting object. The ticker dictionary object that we have has currency symbols as keys.
# get the Bitcoin rates in various currencies
ticker = exchangerates.get_ticker()
By hitting these keys, data about the various rates can be pulled. For instance, the most recent bitcoin rate can be obtained in each currency by getting the p15min minimum value.
# print the Bitcoin price for every currency
print("Bitcoin Prices in various currencies:")
for k in ticker:
print(k, ticker[k].p15min)
A particular currency can also be converted to Bitcoin. For example, you can pass the to_BTC method and pass in the currency and the amount that we want to convert to Bitcoin, and get the result as Bitcoin. The following code shows how to do this for a value of 1000 INR:
# Getting Bitcoin value for a particular amount and currency
btc = exchangerates.to_btc('INR', 1000)
print("\n100 euros in Bitcoin: %s " % btc)