Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
gate_ws
provides Gate.io WebSocket V4 Python implementation, including all channels defined in
spot(new) and futures WebSocket.
Features:
This package requires Python version 3.6+. Python 2 will NOT be supported.
pip install --user gate-ws
import asyncio
from gate_ws import Configuration, Connection, WebSocketResponse
from gate_ws.spot import SpotPublicTradeChannel
# define your callback function on message received
def print_message(conn: Connection, response: WebSocketResponse):
if response.error:
print('error returned: ', response.error)
conn.close()
return
print(response.result)
async def main():
# initialize default connection, which connects to spot WebSocket V4
# it is recommended to use one conn to initialize multiple channels
conn = Connection(Configuration())
# subscribe to any channel you are interested into, with the callback function
channel = SpotPublicTradeChannel(conn, print_message)
channel.subscribe(["GT_USDT"])
# start the client
await conn.run()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
We provide some demo applications in the examples directory, which can be run directly.
from gate_ws import Configuration, Connection
from gate_ws.spot import SpotOrderChannel
async def main():
conn = Connection(Configuration(api_key='YOUR_API_KEY', api_secret='YOUR_API_SECRET'))
channel = SpotOrderChannel(conn, lambda c, r: print(r.result))
channel.subscribe(["GT_USDT"])
# start the client
await conn.run()
import asyncio
async def my_callback(conn, response):
await asyncio.sleep(1)
print(response.result)
from gate_ws import Configuration, Connection
from gate_ws.spot import SpotPublicTradeChannel
async def main():
# provide default callback for all channels
conn = Connection(Configuration(default_callback=lambda c, r: print(r.result)))
# default callback will be used if callback not provided when initializing channels
channel = SpotPublicTradeChannel(conn)
channel.subscribe(["GT_USDT"])
# start the client
await conn.run()
import asyncio
from gate_ws import Configuration, Connection
from gate_ws.spot import SpotPublicTradeChannel
from gate_ws.futures import FuturesPublicTradeChannel
async def main():
# initialize a spot connection, which is the default if no parameters is provided
spot_conn = Connection(Configuration(app='spot'))
# initialize a futures connection
futures_conn = Connection(Configuration(app='futures', settle='usdt', test_net=False))
# subscribe to any channel you are interested into, with the callback function
channel = SpotPublicTradeChannel(spot_conn, lambda c, r: print(r.result))
channel.subscribe(["BTC_USDT"])
channel = FuturesPublicTradeChannel(futures_conn, lambda c, r: print(r.result))
channel.subscribe(["BTC_USDT"])
# start both connection
await asyncio.gather(spot_conn.run(), futures_conn.run())
import concurrent.futures
from gate_ws import Configuration, Connection
from gate_ws.spot import SpotPublicTradeChannel
async def main():
# use process pool to run your callback function
with concurrent.futures.ProcessPoolExecutor() as pool:
conn = Connection(Configuration(executor_pool=pool))
# default callback will be used if callback not provided when subscribing
channel = SpotPublicTradeChannel(conn, lambda c, r: print(r.result))
channel.subscribe(["GT_USDT"])
# start the client
await conn.run()
FAQs
Gate.io WebSocket V4 Python SDK
We found that gate-ws demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.