示例使用开放网关实际路径 /api/v1/open/orders,并已按当前参数生成一份可用签名(timestamp/nonce 为示例值,实际调用请动态生成)。
# POST /api/v1/keys(业务语义路径)
# 网关实际路径:/api/v1/open/orders;sign 由下方脚本计算,5 分钟内有效
curl -X POST 'https://console.maalau.com/api/v1/open/orders?app_key=AK8800000137&nonce=n9527ab&page=1&size=20×tamp=1730000000&sign=c751dbe75f0c5b04b97406c38afedaebd92cea08d9e280a67202beb43e68cd23' \
-H 'Accept: application/json' \
-H 'X-Request-Id: tr-demo-0001'
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: idem-20261119-001' \
-d '{"sku_id":3}'
# 统一响应体
# { "code": 0, "data": ..., "msg": "", "traceId": "tr-8f3c21a0" }const crypto = require('node:crypto');
const appKey = 'AK8800000137', secret = appKey + '.jiutian.secret';
const method = 'POST', path = '/api/v1/open/orders';
const ts = String(Math.floor(Date.now() / 1000)), nonce = 'n9527ab';
const query = { timestamp: ts, nonce, page: '1', size: '20' };
const sortedQuery = Object.keys(query).sort().map(k => k + '=' + query[k]).join('&');
const canonical = [method, path, ts, nonce, sortedQuery].join('\n');
const sign = crypto.createHmac('sha256', secret).update(canonical).digest('hex');
const url = 'https://console.maalau.com' + path + '?' +
new URLSearchParams({ app_key: appKey, ...query, sign }).toString();
const res = await fetch(url, { method, headers: { 'X-Request-Id': 'tr-demo-0001' } });
console.log(await res.json());import hashlib, hmac, time, json
from urllib.parse import urlencode
from urllib.request import urlopen
app_key = 'AK8800000137'
secret = (app_key + '.jiutian.secret').encode()
method, path = 'POST', '/api/v1/open/orders'
ts, nonce = str(int(time.time())), 'n9527ab'
query = {'timestamp': ts, 'nonce': nonce, 'page': '1', 'size': '20'}
sorted_query = '&'.join(f'{k}={query[k]}' for k in sorted(query))
canonical = '\n'.join([method, path, ts, nonce, sorted_query])
sign = hmac.new(secret, canonical.encode(), hashlib.sha256).hexdigest()
url = 'https://console.maalau.com' + path + '?' + urlencode(
{'app_key': app_key, **query, 'sign': sign})
print(json.load(urlopen(url)))
九天