{"id":24455,"library":"python-okx","title":"Python SDK for OKX","description":"Python SDK for OKX exchange API. Version 0.4.1 supports REST and WebSocket APIs, including spot, futures, and options trading. Active development.","status":"active","version":"0.4.1","language":"python","source_language":"en","source_url":"https://github.com/okx/python-okx","tags":["okx","exchange","crypto","api","sdk"],"install":[{"cmd":"pip install python-okx","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"OkxClient is top-level in okx package.","wrong":"from okx.client import OkxClient","symbol":"OkxClient","correct":"from okx import OkxClient"},{"note":"Correct module path is okx.spot.","wrong":"from okx.SpotAPI import SpotAPI","symbol":"SpotAPI","correct":"from okx.spot import SpotAPI"}],"quickstart":{"code":"import os\nfrom okx import OkxClient\n\napi_key = os.environ.get('OKX_API_KEY', '')\nsecret_key = os.environ.get('OKX_SECRET_KEY', '')\npassphrase = os.environ.get('OKX_PASSPHRASE', '')\n\nclient = OkxClient(api_key=api_key, api_secret_key=secret_key, passphrase=passphrase, use_server_time=False, flag='1')\nprint(client.get_ticker('BTC-USDT'))","lang":"python","description":"Initialize client with environment variables and fetch BTC-USDT ticker."},"warnings":[{"fix":"Use `api_secret_key=...` and set `flag='1'` for live trading, `flag='0'` for demo.","message":"In 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.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Call `ws.login(api_key, passphrase, secret_key, timestamp, sign)` on the WebSocket object before subscribing to private channels.","message":"The SDK does NOT handle authentication for WebSocket streams automatically; you must manually authenticate via login endpoint before subscribing to private channels.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from okx import OkxClient`.","message":"The old import path `from okx.client import OkxClient` is deprecated in v0.4.0. It still works but will be removed in future.","severity":"deprecated","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you use `from okx import OkxClient` and have installed version 0.4.x.","cause":"Importing from wrong submodule or old version.","error":"AttributeError: module 'okx' has no attribute 'OkxClient'"},{"fix":"Check that environment variables OKX_API_KEY, OKX_SECRET_KEY, OKX_PASSPHRASE are set correctly and the key is active on OKX.","cause":"API key, secret, or passphrase is incorrect or missing.","error":"okx.exceptions.OkxAPIException: (50001) OKX API key does not exist"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}