skillfed

python-okx

Python SDK for OKX

python-okx v0.4.3 115.6K downloads/30d#12,243 on PyPI
Permissive license Active released

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-okx

uv

uv add python-okx

poetry

poetry add python-okx

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

okx exchange api wrappercryptocurrency trading sdkokx rest websocket clientspot and derivatives tradingokx market data api
trading-apicryptocurrencywebsocket

More Internet packages