## 单个产品行情 ---- 接口:GET /api/v5/market/ticker 描述:获取单个交易产品的最新行情快照,包括最新成交价、买一卖一价、24小时成交量等核心数据。 限频:20次/2s **输入参数** | 名称 | 类型 | 必选 | 描述 | | ---- | ---- | ---- | ---- | | instId | str | Y | 交易产品ID,如 `BTC-USDT`、`BTC-USDT-SWAP` | **输出参数** | 名称 | 类型 | 描述 | | ---- | ---- | ---- | | instType | str | 产品类型(SPOT/SWAP/FUTURES/OPTION) | | instId | str | 交易产品ID | | last | str | 最新成交价 | | lastSz | str | 最新成交量 | | askPx | str | 卖一价 | | askSz | str | 卖一量 | | bidPx | str | 买一价 | | bidSz | str | 买一量 | | open24h | str | 24小时开盘价 | | high24h | str | 24小时最高价 | | low24h | str | 24小时最低价 | | vol24h | str | 24小时成交量(币) | | volCcy24h | str | 24小时成交额(计价货币) | | sodUtc0 | str | UTC 0点开盘价 | | sodUtc8 | str | UTC+8 0点开盘价 | | ts | str | 数据时间戳(毫秒) | **接口示例** ```python import requests BASE_URL = "https://www.okx.com/api/v5" # 获取 BTC-USDT 现货行情 resp = requests.get(f"{BASE_URL}/market/ticker", params={"instId": "BTC-USDT"}) data = resp.json()["data"][0] print(f"最新价: {data['last']}, 24h量: {data['vol24h']}") # 获取 ETH-USDT 永续合约行情 resp = requests.get(f"{BASE_URL}/market/ticker", params={"instId": "ETH-USDT-SWAP"}) data = resp.json()["data"][0] print(f"ETH永续最新价: {data['last']}") ``` **数据样例** ```json { "code": "0", "data": [{ "instType": "SPOT", "instId": "BTC-USDT", "last": "72159", "lastSz": "0.00005196", "askPx": "72157.1", "askSz": "1.44548635", "bidPx": "72157", "bidSz": "0.1012", "open24h": "73554.5", "high24h": "74883", "low24h": "71966", "volCcy24h": "443213018.596221053", "vol24h": "6013.17760207", "ts": "1773842459809", "sodUtc0": "73904.3", "sodUtc8": "73915.5" }] } ```