LoginSignup
15
16

More than 5 years have passed since last update.

PythonからcoincheckのWebsocketAPIに接続する

Posted at

coincheckのWebSocketAPI

wss://ws-api.coincheck.com/

環境

Python 3.6.0 |Anaconda 4.3.0 (64-bit)

websocket-client (0.40.0)

入ってなければ pip install websocket-client

接続(取引履歴)

import json
from websocket import create_connection

ws = create_connection("wss://ws-api.coincheck.com/")

ws.send(json.dumps({
   "type": "subscribe",
   "channel": "btc_jpy-trades"
}))

while True:
    print (ws.recv())

接続(板)

import json
from websocket import create_connection

ws = create_connection("wss://ws-api.coincheck.com/")

ws.send(json.dumps({
   "type": "subscribe",
   "channel": "btc_jpy-orderbook"
}))

while True:
    print (ws.recv())

接続しても返ってこないなーと思っていたら取引が無かっただけでした()

15
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
16