Python WebSocket Guide for Backpack Exchange API
Prerequisites
pip install websockets cryptographypip install python-dotenvPUBLIC_KEY=zDIJj9qneWIY0IYZ5aXoHcNMCm+XDhVcTssiT0HyY0A=
SECRET_KEY=4odxgSUxFrC/zsKWZF4OQwYAgnNu9hnWH3NxWfLAPz4=.envimport json
import asyncio
import websockets
import base64
from time import time
import os
from cryptography.hazmat.primitives.asymmetric import ed25519
from dotenv import load_dotenv, find_dotenvWebSocket API Basics
Why Use Async with WebSockets
Public Streams
Example: Subscribing to a Public Stream
Example: Subscribing to Multiple Public Streams
Private Streams
Authentication for Private Streams
Example: Subscribing to a Private Stream
WebSocket Ping/Pong
Sources
Last updated
