接入文档
标准 HMAC 签名 + 完整 OpenAPI 文档,5 分钟完成对接
📘
OpenAPI 接口文档
在线 Swagger 文档,支持接口调试、参数说明、响应示例。生产环境默认关闭,可通过环境变量开启。
🔌
第三方接入指南
完整签名算法说明、错误码表、SDK 调用示例(Node.js / Java / Python / Go),可直接复制使用。
📖
平台使用帮助
通道配置、模板管理、批量发送、告警设置等操作的图文教程,新手必读。
快速接入代码示例(多语言)
const crypto = require('crypto');
const API_KEY = 'your_api_key';
const API_SECRET = 'your_api_secret';
const BASE_URL = 'https://your-domain.com/api/v1';
// 签名串:timestamp \n nonce \n METHOD \n path \n body
function sign(method, path, body, timestamp, nonce) {
const message = [timestamp, nonce, method.toUpperCase(), path, body].join('\n');
return crypto.createHmac('sha256', API_SECRET).update(message).digest('hex');
}
async function sendSms(mobile, templateCode, params) {
const body = JSON.stringify({ mobile, templateCode, params });
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomBytes(8).toString('hex');
const signature = sign('POST', '/api/v1/sms/send', body, timestamp, nonce);
const resp = await fetch(BASE_URL + '/api/v1/sms/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': API_KEY,
'X-Timestamp': timestamp,
'X-Nonce': nonce,
'X-Signature': signature,
},
body,
});
return resp.json(); // 异步受理:{ status: "pending", requestId }
}
sendSms('13800000000', 'TPL_001', { code: '1234' }).then(console.log);