Apis tips for checking bitcoin quotes

Asked

Viewed 858 times

0

Hello, I’m new to this Bitcoin thing, and I looked for some Apis to check the currency quotes, however the ones I found I didn’t quite understand how these work, someone who understands more of the subject can help me by recommending some easy-to-use API?

  • Speaks @Matheusgrossi! The question is wide open. Can you show what you tried? Or narrow the question to a specific API?

  • So, I’m trying to make a script in Python that checks the Bitcoin quotation in real time, so that later I use this information for other purposes, however at first the intention is just to check how much this is worth at the time the script is executed...

  • What API have you used? You can show the part that is doing the query in this script?

  • Initially I used one called Bitcoin-Python, and regarding the script I did several "drafts" of this, however none of them presented me the desired result, so these were deleted without the possibility of recovery.

1 answer

1


There is the Bitcoin Market API, it is extremely simple and lightweight works with JSON. It is public does not need authentication for prices

https://www.mercadobitcoin.net/api/BTC/ticker/

Returns

{"ticker": 
    {"high": "17770.00000000", 
     "low": "17420.00000000", 
     "vol": "316.44974311", 
     "last": "17430.90199000", 
     "buy": "17430.90199000", 
     "sell": "17487.00000000", 
     "date": 1508016142
    }
}

Already to make a function becomes very simple with python

    import json
    import urllib2

    def get_btc():
        response = urllib2.urlopen('https://www.mercadobitcoin.net/api/BTC/ticker/')
        json_str = response.read()
        btc_data = json.loads(json_str)
        return btc_data['ticker']

btc_ticker = def get_btc()

 print "O preco do Bitcoin agora e: R$ {:.2f}".format(float(btc_ticker['last']))
  • Friend, thanks for the recommendation tested here and worked well, however as I am new in Python could just explain me what makes the part "['Ticker']" after the "Return btc_data"...

  • JSON is converted to a python dictionary. In this dictionary has the key "Ticker" and inside it has another dictionary that has the price information. Then I sent back only the dictionary that has the prices.

  • Thank you friend! I was no north until the moment you clarified everything to me!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.