Registry / http-networking / python-okx

python-okx

JSON →
library0.4.1pypypi✓ verified 80d ago

Python SDK for OKX exchange API. Version 0.4.1 supports REST and WebSocket APIs, including spot, futures, and options trading. Active development.

pip install python-okx
INSTALL
IMPORT
SIG · PYTHON-OKX
P
python-okx
http-networkingpythonv0.4.1
Install
9.0s avg
Import
Disk
74MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 73.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 9.0s · import 0.000s · 74MB
74MB installed
● package 74MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OkxClient
import okx
from okx import OkxClient

Initialize client with environment variables and fetch BTC-USDT ticker.

import os from okx import OkxClient api_key = os.environ.get('OKX_API_KEY', '') secret_key = os.environ.get('OKX_SECRET_KEY', '') passphrase = os.environ.get('OKX_PASSPHRASE', '') client = OkxClient(api_key=api_key, api_secret_key=secret_key, passphrase=passphrase, use_server_time=False, flag='1') print(client.get_ticker('BTC-USDT'))
Debug
Known issues
breakingIn v0.4.x, the constructor parameter 'api_secret_key' replaces the old 'apiSecretKey'. Also, 'flag' parameter default changed from '0' (simulated) to '' (empty), requiring explicit flag for live trading.
fix
Use `api_secret_key=...` and set `flag='1'` for live trading, `flag='0'` for demo.
affects: >=0.4.0
gotchaThe SDK does NOT handle authentication for WebSocket streams automatically; you must manually authenticate via login endpoint before subscribing to private channels.
fix
Call `ws.login(api_key, passphrase, secret_key, timestamp, sign)` on the WebSocket object before subscribing to private channels.
affects: all
deprecatedThe old import path `from okx.client import OkxClient` is deprecated in v0.4.0. It still works but will be removed in future.
fix
Use `from okx import OkxClient`.
affects: >=0.4.0
Upgrade
Version history
0.4.1latest on PyPI · released Jan 8, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
38
Resources
python-okx — pip install python-okx · libregistry