Rurix REST API v1,供程序化交易使用。创建 Key:账户中心 → API 管理。
{
"code": 0,
"msg": "ok",
"data": {}
}
code=0 表示成功;非 0 时 data 一般为 null。
在账户中心创建 API Key 后,私有接口请带以下请求头:
X-ACCESS-KEYX-ACCESS-TIMESTAMP(毫秒时间戳)X-ACCESS-SIGN(HMAC-SHA256 十六进制)timestamp METHOD path query body
path 含 /api/v1/...,不含 query。query 为原始 QUERY_STRING,无则空串;body 为原始请求体,无则空串。可选 recvWindow(毫秒,默认 5000,最大 60000)。也兼容旧版 WS:HMAC(secret, access_id={key}&tonce={ts})。
import hmac, hashlib, time, requests
base = "https://api.rurix.org/api/v1"
key, secret = "rx_xxx", "your_secret"
ts = str(int(time.time() * 1000))
method, path = "GET", "/api/v1/account/balance"
query, body = "asset=USDT", ""
payload = "\n".join([ts, method, path, query, body])
sign = hmac.new(secret.encode(), payload.encode(), hashlib.sha256).hexdigest()
r = requests.get(base + "/account/balance", params={"asset": "USDT"}, headers={
"X-ACCESS-KEY": key,
"X-ACCESS-TIMESTAMP": ts,
"X-ACCESS-SIGN": sign,
})
print(r.json())
市价买入现货用 quoteOrderQty(计价币金额);市价卖出用 quantity。合约 BUY=开多,SELL=开空。
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/ping | 存活探测 | 无 {"pong":true} |
| GET | https://api.rurix.org/api/v1/time | 服务器时间(毫秒) | 无 {"serverTime":1727610000000} |
| GET | https://api.rurix.org/api/v1/system/status | 现货/合约/充提开关 | 无 |
| GET | https://api.rurix.org/api/v1/exchangeInfo | 全部交易对规则 | 无 |
| GET | https://api.rurix.org/api/v1/exchangeInfo/spot | 现货交易对规则 | 无 |
| GET | https://api.rurix.org/api/v1/exchangeInfo/futures | 合约规则与杠杆档位 | 无 |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/market/symbols | 交易对列表 | 无 |
| GET | https://api.rurix.org/api/v1/market/depth | 深度 | symbol, limit(1-100,默认20) |
| GET | https://api.rurix.org/api/v1/market/trades | 最近成交 | symbol, limit |
| GET | https://api.rurix.org/api/v1/market/ticker | 单币 ticker | symbol |
| GET | https://api.rurix.org/api/v1/market/ticker/24hr | 24h 行情;不传 symbol 则全市场 | symbol? |
| GET | https://api.rurix.org/api/v1/market/tickers | 全部 ticker | 无 |
| GET | https://api.rurix.org/api/v1/market/klines | K线 | symbol, interval(1m/5m/15m/30m/1h/4h/1d/1w), limit, startTime, endTime [openTime,open,high,low,close,volume] |
| GET | https://api.rurix.org/api/v1/market/avgPrice | 最新价 | symbol |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| POST | https://api.rurix.org/api/v1/spot/order | 下单 LIMIT/MARKET | symbol, side(BUY|SELL), type, quantity, price?, quoteOrderQty?, newClientOrderId? TRADE |
| DELETE | https://api.rurix.org/api/v1/spot/order | 撤单 | symbol, orderId TRADE |
| GET | https://api.rurix.org/api/v1/spot/order | 查单 | symbol, orderId READ |
| GET | https://api.rurix.org/api/v1/spot/openOrders | 当前委托 | symbol, limit, offset READ |
| DELETE | https://api.rurix.org/api/v1/spot/openOrders | 按交易对撤全部 | symbol TRADE |
| GET | https://api.rurix.org/api/v1/spot/allOrders | 历史委托 | symbol, limit, offset, startTime, endTime READ |
| GET | https://api.rurix.org/api/v1/spot/myTrades | 我的成交 | symbol, limit, offset READ |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/futures/exchangeInfo | 合约规则(公开) | 无 公开 |
| GET | https://api.rurix.org/api/v1/futures/depth | 深度(复用现货盘口,公开) | symbol, limit 公开 |
| GET | https://api.rurix.org/api/v1/futures/trades | 最近成交(公开) | symbol, limit 公开 |
| GET | https://api.rurix.org/api/v1/futures/ticker | ticker / markPrice(公开) | symbol 公开 |
| GET | https://api.rurix.org/api/v1/futures/klines | K线(公开) | symbol, interval, limit, startTime, endTime 公开 |
| GET | https://api.rurix.org/api/v1/futures/openInterest | 持仓量(公开) | symbol 公开 |
| GET | https://api.rurix.org/api/v1/futures/premiumIndex | 标记价;资金费率暂为 0(公开) | symbol 公开 |
| POST | https://api.rurix.org/api/v1/futures/order | 开多/开空 | symbol, side(BUY=多|SELL=空), type, leverage, quantity, price?, positionSide? TRADE |
| DELETE | https://api.rurix.org/api/v1/futures/order | 撤销未开仓委托 | orderId TRADE |
| GET | https://api.rurix.org/api/v1/futures/order | 查委托/仓位单 | orderId READ |
| GET | https://api.rurix.org/api/v1/futures/openOrders | 未开仓委托 | symbol READ |
| GET | https://api.rurix.org/api/v1/futures/positionRisk | 当前持仓 | symbol? READ |
| POST | https://api.rurix.org/api/v1/futures/position/close | 手动全平 | orderId 或 positionId TRADE |
| GET | https://api.rurix.org/api/v1/futures/userTrades | 开平仓历史 | symbol READ |
| GET | https://api.rurix.org/api/v1/futures/income | 盈亏/手续费 | asset?, page, limit READ |
| GET | https://api.rurix.org/api/v1/futures/forceOrders | 强平历史 | symbol? READ |
| GET | https://api.rurix.org/api/v1/futures/balance | 合约余额 | 无 READ |
| GET | https://api.rurix.org/api/v1/futures/ledger | 合约流水 | asset?, page, limit READ |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/account | 账户与权限 | 无 READ |
| GET | https://api.rurix.org/api/v1/account/balance | 现货余额 | asset? READ |
| GET | https://api.rurix.org/api/v1/account/asset | 现货+合约资产 | 无 READ |
| POST | https://api.rurix.org/api/v1/account/transfer | 现货↔合约划转 | asset, amount, type(SPOT_TO_FUTURES|FUTURES_TO_SPOT) TRADE |
| GET | https://api.rurix.org/api/v1/account/transfer | 划转历史 | asset?, page, limit READ |
| GET | https://api.rurix.org/api/v1/account/ledger | 现货流水 | asset?, page, limit READ |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/capital/deposit/address | 充值地址 | asset, network? READ |
| GET | https://api.rurix.org/api/v1/capital/deposit/history | 充值记录 | asset?, page, limit READ |
| GET | https://api.rurix.org/api/v1/capital/withdraw/history | 提现记录 | asset?, page, limit READ |
| GET | https://api.rurix.org/api/v1/capital/config/getall | 币种充提配置 | 无 READ |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| GET | https://api.rurix.org/api/v1/apiKeys | Key 列表(Secret 脱敏) | 无 READ |
| POST | https://api.rurix.org/api/v1/apiKeys | 创建 Key(Secret 仅返回一次) | permTrade?, ip?, remark? TRADE |
| DELETE | https://api.rurix.org/api/v1/apiKeys/{id} | 删除 Key(不可删当前使用的) | 路径 id TRADE |
| PUT | https://api.rurix.org/api/v1/apiKeys/{id}/ip | 修改 IP 白名单 | ip TRADE |
| Method | Path | 说明 | 参数 |
|---|---|---|---|
| POST | https://api.rurix.org/api/v1/userDataStream | 创建 listenKey(约 1 小时) | 无 READ |
| PUT | https://api.rurix.org/api/v1/userDataStream | 续期 | listenKey READ |
| DELETE | https://api.rurix.org/api/v1/userDataStream | 关闭 | listenKey READ |
| code | HTTP | 说明 |
|---|---|---|
| 0 | 200 | 成功 |
| 40001 | 400 | invalid symbol |
| 40101–40106 | 401/403 | 缺签名 / 过期 / Key 无效 / IP 不允许 / 缺 TRADE 权限 |
| 40310 | 403 | 程序提现关闭 |
| 50301 | 503 | API 总开关关闭 |
后台 API 开关关闭时,全部 /api/v1 返回 50301。程序提现默认关闭。