python-okx
Python SDK for OKX
What it is and what it does
python-okx is an unofficial Python client library for trading on the OKX cryptocurrency exchange. It wraps OKX's v5 REST API and WebSocket endpoints, allowing you to execute spot and derivatives trades, query account balances, retrieve market data, and manage orders programmatically. The library handles both public (market data) and private (authenticated trading) operations, with support for live trading and testnet/demo environments.
The package provides a straightforward object-oriented interface—you instantiate API classes like Account or Trade with your credentials, then call methods to interact with the exchange. It includes WebSocket support with automatic reconnection and connection multiplexing for real-time data streams. Dependencies are lightweight and standard (httpx, requests, websockets, certifi, loguru), making it straightforward to integrate into trading bots, portfolio dashboards, or research scripts.
Use it for:
- Build automated spot trading bots that execute buy/sell orders based on market conditions or signals
- Retrieve real-time market data and order book snapshots via WebSocket for technical analysis
- Manage derivatives positions (futures, perpetuals) programmatically with leverage and risk controls
- Monitor account balances, positions, and trading history for portfolio tracking dashboards
- Test trading strategies on OKX testnet before deploying to live trading with flag parameter
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Unofficial Python wrapper for the OKX exchange v5 API, providing REST and WebSocket access to spot and derivatives trading, account management, and market data.
Yes, if you trade on OKX and need programmatic access. The package is actively maintained, has low install friction, carries no known security vulnerabilities, and is licensed permissively. Verify that its API endpoint coverage matches your trading needs and that WebSocket reconnection behavior suits your use case before deploying to production.
Install
python-okx on PyPI
pip
pip install python-okxuv
uv add python-okxpoetry
poetry add python-okxInstalling python-okx
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance status with a recent release (38 days ago). Depends on common libraries: httpx, requests, websockets, certifi, and loguru.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install python-okx
from okx import Account
account = Account.AccountAPI(
api_key="your-api-key",
api_secret_key="your-api-secret",
passphrase="your-passphrase",
flag="1"
)
Requires OKX API credentials (API key, secret, passphrase) obtained from your OKX account; Python >=3.7
Verify before relying
- Whether WebSocket reconnection and multiplexing are production-ready or still experimental
- Performance characteristics under high-frequency trading or large order volumes
- Completeness of API endpoint coverage relative to the latest OKX v5 API specification
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — httpx, requests, websockets, certifi, loguru |
| Maintenance | actively maintained — 38 days since the last release |
| First released | |
| Downloads | 115,564/month — #12,243 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_okx-0.4.3-py3-none-any.whl
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
python-binanceUnofficial Python wrapper for the Binance…
permissive · top 15,000 on PyPI
python-kraken-sdkProvides REST and WebSocket clients for trading…
permissive · top 15,000 on PyPI
binance-connectorConnects Python applications to Binance's…
permissive · top 15,000 on PyPI
ccxtCCXT is a unified API library for connecting to…
permissive · top 5,000 on PyPI
hyperliquid-python-sdkPython SDK for trading on the Hyperliquid…
permissive · top 15,000 on PyPI
coinbase-advanced-pyOfficial Python SDK for the Coinbase Advanced…
permissive · top 15,000 on PyPI
pybitpybit is the official Python connector for…
permissive · top 15,000 on PyPI
tradingview-taRetrieves technical analysis indicators and…
permissive · top 15,000 on PyPI
tardis-clienttardis-client is a deprecated Python client for…
copyleft · top 15,000 on PyPI
kiteconnectOfficial Python client for the Kite Connect…
permissive · top 15,000 on PyPI