kabu Station® API --Updated Python wrapper for PUSH API

Overview

python-kabusapi Created Python wrapper for kabu station API is REST Only API was supported, and websocket distribution by PUSH API was not supported.

Therefore, it was necessary to write a code such as "Receive Websocket of kabu station ® API in Python", but for beginners asyncio Since the concept such as: //docs.python.org/ja/3.8/library/asyncio.html) is complicated, the library has been updated so that it can be eliminated.

environment

Additional packages

code

import kabusapi

url = "localhost"
port = "18081"  #For verification,18080 for production

#Initial setting: No token password required for PUSH distribution
api = kabusapi.Context(url, port,)

#Receiving function This is called every time information is received
@api.websocket
def recieve(msg):
    #The msg processed here is in dict format.
    print("{} {} {}".format(
        msg['Symbol'],
        msg['SymbolName'],
        msg['CurrentPrice'],
    ))

#Start receiving
api.websocket.run()

Recommended Posts

kabu Station® API --Updated Python wrapper for PUSH API
kabu Station® API-I made a Python wrapper for REST API
Implemented Python wrapper for Qiita API v2
Created a Python wrapper for the Qiita API
Receive websocket of kabu station ® API in Python
Qiita API Python wrapper for batch processing to grab Qiita posts
I made a Python wrapper library for docomo image recognition API.
Google Cloud Vision API sample for python
Touch the sample v20-python-samples of the OANDA v20 REST API wrapper library for Python
Tweet (API 1.1) on Google App Engine for Python
Tips for hitting the ATND API in Python
Try using kabu station API of kabu.com Securities
I made a Python Qiita API wrapper "qiipy"
2016-10-30 else for Python3> for:
python [for myself]
Updated to Python 2.7.9
[BigQuery] How to use BigQuery API for Python -Table creation-
Push notifications from Python to Android using Google's API