SDK Documentation
Choose your language and integrate SMS sending in minutes.
Installation
terminal
npm install @maiyun/sms
Send SMS
Node.jssend.mjs
import { SmsClient } from '@maiyun/sms';
const client = new SmsClient('YOUR_API_KEY');
// --- send ---
const result = await client.send({
phone: '8613800138000',
text: 'Your verification code is 123456, valid for 5 minutes.',
});
if (result.result === 1) {
console.log('uid:', result.uid);
} else {
console.error('error:', result.error);
}Important Notes
1Phone numbers must include country code, e.g. 8613800138000 (86 = China Mainland).
2Keep your API Key secret. Never expose it in client-side code; use environment variables.
3Messages over 160 chars (70 for Chinese) are auto-split into multiple segments.
4Save the returned uid to track delivery status in the console.