Async (trio) KuCoin minimal REST API + Websocket

Overview

Minimal Async KuCoin REST API + WebSocket using trio

Coded by π ([email protected] TG: @pipad) 22 January 2022

KuCoin needs an async Python client

This code may serve as a foundation for an async Python KuCoin API.

Publishing it is an invitation for others to build upon a solid foundation. You are welcome to build it out. Just please, keep it clean and do your best to balance all forces: abstraction, functionality, clarity, ...

What this code does

The two wings are: REST API (via httpx) and WebSocket Client (via trio-websocket)

This minimal example demonstrates both wings.

It fetches a websocket token (which requires a REST API call) and connects to a websocket.

How to get it running

> pip install arrow trio trio-websocket httpx[http2]

Also create a ../kucoin.json file (i.e. in parent of repo home-folder):

{
    "api_key": "...",
    "api_secret": "...",
    "api_passphrase": "..."
}

To run:

python main.py

on trio vs asyncio

For network-centric programming threads are the past, async is the future.

However, asyncio (the Python stdlib offering) is a mess. It evolved gradually as Python developed concepts of async programming. It is therefore stuck with the burden of backward compatibility with itself. asyncio code is hard to read, hard to write, hard to debug, hard to maintain.

trio is a beautiful from-the-ground-up async library that has learned from the mistakes of asyncio. It is clean, intuitive and sports a vibrant gitter community.

We should all be using trio, and asyncio should be thanked for its efforts and put to rest.

You might also like...
Benchmark a WebSocket server's message throughput ⌛
Benchmark a WebSocket server's message throughput ⌛

📻 WebSocket Benchmarker ⌚ Message throughput is how fast a WebSocket server can parse and respond to a message. Some people consider this to be a goo

wssh ("wish") is a command-line utility/shell for WebSocket inpsired by netcat.

wssh ("wish") is a command-line utility/shell for WebSocket inspired by netcat

Whatsapp Clone using django, django-channels and websocket
Whatsapp Clone using django, django-channels and websocket

whatsapp-clone Whatsapp Clone using django, django-channels and websocket Features : Signup/Login One on One personal chat with other user Some screen

Minecraft WebSocket

Minecraft-WebSocket Pythonでマインクラフトと通信します。 紹介動画 推奨設定 Minecraft Windows Edition (Education Edition) 1.17 以上 Python 3系(3.8.2で動作確認済み) 必要なモジュール ・asyncio ・w

Tetri5 - Multiplayer Websocket Backend

Tetri5 - Multiplayer Websocket Backend This repository is the backend of the multiplayer portion of the Tetri5 game client. It uses the python websock

alien.py - Python interface to websocket endpoint of ALICE Grid Services

alien.py - Python interface to websocket endpoint of ALICE Grid Services Quick containerized testing: singularity

image stream publish server over websocket
image stream publish server over websocket

Image Stream Push Server 简介 通过浏览器网页实时查看图像处理结果。 环境 运行程序需要安装一下python依赖: tornado: 用于创建http及websocket服务; opencv-contrib-python: 用于图像数据源获取及图像处理。 使用 进入到src目

Discord.py Connect to Discord voice call with websocket

Discord.py Connect to Discord voice call with websocket

A websocket client for Source Filmmaker intended to trasmit scene and frame data to other applications.

SFM SOCK A websocket client for Source Filmmaker intended to trasmit scene and frame data to other applications. This software can be used to transmit

Owner
Pi
Math -> Software Engineer -> CTO -> CEO UnitCircle Ltd. (DSP/ML/Mob/Cloud Technical Solutions)
Pi
WebSocket and WAMP in Python for Twisted and asyncio

Autobahn|Python WebSocket & WAMP for Python on Twisted and asyncio. Quick Links: Source Code - Documentation - WebSocket Examples - WAMP Examples Comm

Crossbar.io 2.4k Jan 4, 2023
Library for building WebSocket servers and clients in Python

What is websockets? websockets is a library for building WebSocket servers and clients in Python with a focus on correctness and simplicity. Built on

Aymeric Augustin 4.3k Jan 4, 2023
WebSocket client for Python

websocket-client The websocket-client module is a WebSocket client for Python. It provides access to low level APIs for WebSockets. All APIs are for s

null 3.1k Jan 2, 2023
Django Channels HTTP/WebSocket server

daphne Daphne is a HTTP, HTTP2 and WebSocket protocol server for ASGI and ASGI-HTTP, developed to power Django Channels. It supports automatic negotia

Django 1.9k Dec 31, 2022
Websockify is a WebSocket to TCP proxy/bridge. This allows a browser to connect to any application/server/service. Implementations in Python, C, Node.js and Ruby.

websockify: WebSockets support for any application/server websockify was formerly named wsproxy and was part of the noVNC project. At the most basic l

noVNC 3.3k Jan 3, 2023
WebSocket emulation - Python server

SockJS-tornado server SockJS-tornado is a Python server side counterpart of SockJS-client browser library running on top of Tornado framework. Simplif

Serge S. Koval 854 Nov 19, 2022
一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK

Nakuru Project 一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK 在 kuriyama 的基础上改动 项目名来源于藍月なくる,图标由せら绘制 食用方法 将 nakuru 文件夹移至 Python 的 Lib/site-packages 目录下。

null 35 Dec 21, 2022
This websocket program is for data transmission between server and client. Data transmission is for Federated Learning in Edge computing environment.

websocket-for-data-transmission This websocket program is for data transmission between server and client. Data transmission is for Federated Learning

null 9 Jul 19, 2022
Using python-binance to provide websocket data to freqtrade

The goal of this project is to provide an alternative way to get realtime data from Binance and use it in freqtrade despite the exchange used. It also uses talipp for computing

null 58 Jan 1, 2023
WebSocket implementation in Python built on top of websockets python library. Similar to Node.js's ws.

ws WebSocket implementation in Python built on top of websockets python library. Similar to Node.js's ws. Basic usage. server.py import ws server = w

AceExpert 7 Jun 27, 2022