Skip to content

Commit

Permalink
Merge pull request #877 from erhan/master
Browse files Browse the repository at this point in the history
btcturk new api fix.
  • Loading branch information
tresni authored Oct 10, 2017
2 parents 5f7dcb8 + e1540b4 commit 96669a6
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions Cryptocurrency/Bitcoin/tr-markets.1m.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,38 @@


def get_btcturk_price():
conn = http.client.HTTPSConnection("www.btcturk.com")
conn.request("GET", "/api/ticker")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
return data["ask"]
try:
conn = http.client.HTTPSConnection("www.btcturk.com")
conn.request("GET", "/api/ticker")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
for item in data:
if item["pair"] == "BTCTRY":
return item["ask"]
except:
return 0
return 0


def get_koinim_price():
conn = http.client.HTTPSConnection("koinim.com")
conn.request("GET", "/ticker/")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
return data["ask"]
try:
conn = http.client.HTTPSConnection("koinim.com")
conn.request("GET", "/ticker/")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
return data["ask"]
except:
return 0

def get_paribu_price():
conn = http.client.HTTPSConnection("www.paribu.com")
conn.request("GET", "/ticker")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
return data["BTC_TL"]["last"]
try:
conn = http.client.HTTPSConnection("www.paribu.com")
conn.request("GET", "/ticker")
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
return data["BTC_TL"]["last"]
except:
return 0


print("BTCTURK : " + "{0:.2f}".format(get_btcturk_price()) +" TRY")
Expand Down

0 comments on commit 96669a6

Please sign in to comment.