The following steps shows the method for bitcoin exchange rates:
- First, import the exchangerates classes from the blockchain library:
#!/usr/bin/env python# import blockchain libraryfrom blockchain import exchangerates
- 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 currenciesticker = exchangerates.get_ticker()
- By running over these keys, data about the various rates can be pulled. For example, the latest bitcoin rates can be obtained in each currency by getting the p15min