ãã£ããä»®æ³é貨ã¨Pythonã軸ã®ããã°ããã£ã¦ããã®ã§ãcoinexchangeã®apiãå©ãã¦ã¿ãã¨ããè¨äºãæ¸ãã¦ã¿ããã¨æãã¾ãã
ä»åããã®ã¯ãã·ã³ãã«ã«ã¿ã¼ããã«ããPythonã®ã¹ã¯ãªãããå¼ã³åºãã¦ãXP/BTCãXP/DOGEã表示ããã ãã
Currently we are only providing a Public API which does not use authentication. We will be releasing API V2 with full trade and coin control functionality at a later stage.
ã¨coinchangeã®apiã®ãã¼ã¸ã«ããããã«ãç¾æç¹ã§ã¯ããã¬ã¼ããªã©ãã§ããæ©è½ã¯æä¾ãã¦ããªãããã§ãã
apiã®èª¬æ
coinchangeã®apiã«ã¤ãã¦ã¯ãã©ã®ããã«å ¬å¼ã«ã©ã®ããã«ã¢ã¯ã»ã¹ããã°ãã©ã®ãããªå¤ãåå¾ã§ãããæ¸ãã¦ãã¾ãã
'https://www.coinexchange.io/api/v1/getmarkets'ã®å¾ãã«ã以ä¸ã®è¡¨ã®ãURLã«ä»å ããURLããã¤ãã¦ã¢ã¯ã»ã¹ãã¦ãããã°ï¼ã¯ã¨ãªãæããã¨ï¼ããå 容ãæ¬ã«æ¸ãã¦ããå 容ã帰ã£ã¦ãã¾ãã
URLã«ä»å ããURL | å 容 |
---|---|
getmarkets | åãæ±ã£ã¦ããã³ã¤ã³ã®IDãªã©ãè¿ã |
getmarketsummaries | å ¨ã¦ã®ã³ã¤ã³ã®ãµããªã¼ãè¿ã |
getmarketsummary?market_id=1 | getmarketsummariesãä¸ã¤ã®ã³ã¤ã³ã«ç¹å® |
getorderbook?market_id=1 | the top 50 buy and sell order for the market. |
getcurrencies | å ¨ã¦ã®ã³ã¤ã³ã®ãªã³ã©ã¤ã³ããªãã©ã¤ã³çãè¿ã |
getcurrency?currency_id=1 | getcurrenciesãï¼ã¤ã®ã³ã¤ã³ã«ç¹å® |
ï¼æ³¨ï¼å ¬å¼ã«è¨è¼ãããããthe top 50 buy and sell order for the market.ãã¨ã¯ä½ãªãã§ãããï¼
APIã«ã¢ã¯ã»ã¹ãã¦ã¿ãã
ãã©ã¦ã¶ããhttps://www.coinexchange.io/api/v1/getmarketsummary?market_id=137ã«ã¢ã¯ã»ã¹ãã¦ã¿ã¾ãããã以ä¸ã®ããã«XP/DOGEã®ä¾¡æ ¼çã表示ãããã®ããããã¾ãããªãmarket_idã135ã«ããã¨XP/BTCã®ä¾¡æ ¼ãåå¾ã§ãã¾ãã
Pythonã§åå¾ããã
ä»åã¯ã詳ããã¯è§£èª¬ãã¾ãããã以ä¸ã®ããã«ãXP/DOGEã®ç¾å¨ã®ä¾¡æ ¼ãä»æ¥ã®é«å¤ãä»æ¥ã®å®å¤ãXP/BTCã®ç¾å¨ã®ä¾¡æ ¼ã表示ããã³ã¼ããæ¸ãã¦ã¿ã¾ããã
def xp(): import requests from datetime import datetime print(datetime.now().strftime("%Y/%m/%d %H:%M:%S")) response = requests.get('https://www.coinexchange.io/api/v1/getmarketsummaries').json() print(response['result'][84]['LastPrice'], 'ããï¼ç¾å¨ã®ä¾¡æ ¼ï¼') print(response['result'][84]['HighPrice'], 'ããï¼ä»æ¥ã®é«å¤ï¼') print(response['result'][84]['LowPrice'], 'ããï¼ä»æ¥ã®å®å¤ï¼') print(response['result'][82]['LastPrice'], 'ããï¼BTCï¼') if __name__ == '__main__': xp()
å®è¡ããã¨ã以ä¸ã®ããã«ãç¾å¨ã®ä¾¡æ ¼ãªã©ã表示ããã¾ããã
ã¾ã¨ã
ã¨ããããã¬ã¼ãã表示ã§ããã®ã§ã次ã®stepã«é²ãããã§ããï¼slackã®botãä½ãã¨ããtwitterã®botãä½ãã¨ãï¼
æ©æ¢°å¦ç¿ã§ãå¤åããåæããã¨ãä»å¾ãããããããã®ç¶ãã¯ã¾ãæéãããã¨ãã«æ¸ãã¾ãã '