728x90

파이썬 - 빗썸 API 이용한 코인 정보 가져오기

빗썸 API - apidocs.bithumb.com/docs/ticker

Public API 참고

소스

from urllib.request import urlopen
import json

order_currency = "BTC" # 검색 화폐
payment_currency = "KRW"

BASE_URL = "https://api.bithumb.com/public/ticker/{}_{}".format(order_currency, payment_currency)
response = urlopen(BASE_URL).read().decode('utf-8')
responseJson = json.loads(response)

print(responseJson.get("status")) # 결과 상태 코드 (정상: 0000, 그 외 에러 코드 참조)
print(responseJson.get("data").get("opening_price")) # 시가 00시 기준
print(responseJson.get("data").get("closing_price")) # 종가 00시 기준

 

 

+ Recent posts