코인원 도큐멘터리 : http://doc.coinone.co.kr/
마풀허 : https://github.com/MPOS/php-mpos/wiki/API-Reference
python에서 사용할 모듈은 request, re입니다.
-마풀허-
기본적으로 http로
https://마풀허풀주소/index.php?page=api&action=얻고싶은정보&api_key=자신의apikey
를 요청하면 해당 정보가 날아와서, 이를 파싱해서 사용하시면 됩니다. ( 인터넷 브라우저에 쳐 보면 정보가 뜨는걸 볼수있어요!)
아래 예시코드에는getpoolstatus를 사용하여 현재 난이도를 얻어오는데에 사용하였고, 다른 명령어들은 마풀허 document에서 가져오시면 됩니다.
-코인원-
제가 개인api는 아직 사용해보지 않아서 public정보만 다뤄본걸로 설명드리겠습니다..
비슷한 방식입니다. 예를들어 이더리움 관련 public 정보는 다음 주소들을 이용하시면 됩니다.
https://api.coinone.co.kr/currency/?format=json¤cy=eth 현재 시세
https://api.coinone.co.kr/orderbook/?format=json¤cy=eth 오더북(호가 창)
https://api.coinone.co.kr/trades/?format=json¤cy=eth 최근 완료된 거래들
https://api.coinone.co.kr/ticker/?format=json¤cy=eth 현재 코인 상태
당장 위 주소들을 브라우저에서 넣어 보시면 정보가 뜹니다. eth를 xrp, eth, etc, btc등으로 바꾸면 다른 코인도 뜨구요
도움이 조금이라도 되셨다면 추천한방 부탁드립니당!@!!
----------------------예시 프로그램 : 이더 해쉬에 따른 하루당 얻을수있는 이더 및 가격---------------------------------------
import requests
import re
api_key = "자신의 마풀허 api 키 (마풀허 정보수정 란에 있음)"
tail = "&api_key="+str(api_key)
header = "https://ethereum.miningpoolhub.com/index.php?page=api&action="
def get_data(apiname):
result = requests.get(header+apiname+tail)
return result.text
def first_substring(strings, substring):
return next(i for i, string in enumerate(strings) if substring in string)
data = get_data("getpoolstatus").split(",")
D = float(re.sub("\D", "", data[first_substring(data,"networkdiff")]))
Currency = requests.get("https://api.coinone.co.kr/ticker/?format=json¤cy=eth").text.split(",")
Currency = int(re.sub("\D", "", Currency[first_substring(Currency, "last")]))
while(True):
print "\n\n\nCalculate Money with hashrate : 1"
print "Just Display information : 2"
print "Exit : 3\n"
user_input = int(raw_input("Input : "))
if(user_input is 3) : break
if(user_input is 1):
Hashrate = float(raw_input('Put hashrate here : '))
CoinPerHour = (5 / D) * 1000 * 1000 * 3600 * 24
Money = CoinPerHour * Currency * Hashrate
print "You can get %f ETH per hour" % (CoinPerHour*Hashrate)
print "You can get %f Won per hour" % (Money)
if (user_input is 2):
print "Current Difficulty : %d" % D
print "Currency now is : %d / ETH" % Currency
------------------------------------------------------------------------------------------------------------------