andiwagateway
v1.2.0
Published
Official SDK for Andi WA Gateway - WhatsApp API integration made simple. Supports 40+ endpoints including reactions, polls, stories, and more.
Maintainers
Readme
Andi WA Gateway SDK
SDK Official untuk Andi WA Gateway
Tinggal pasang API Key, langsung kirim pesan WhatsApp!
🎯 Fitur
- ✅ API Key Only - Tidak perlu setup server, tinggal API Key
- ✅ Session Auto-Detect - Tidak perlu pilih session, otomatis dari API Key
- ✅ Base URL Built-in - Sudah terkonfigurasi ke
andi-wa-gateway.up.railway.app - ✅ OTP Plugin - Kirim kode verifikasi dengan 1 baris kode
- ✅ Webhook Handler - Terima pesan masuk dengan mudah
- ✅ Express Ready - Middleware siap pakai
- ✅ 40+ API Endpoints - Pesan, media, reaksi, polling, story, dan lebih banyak!
📦 Install
npm install andiwagateway🚀 Quick Start
1. Kirim Pesan (Basic)
const sdk = require('andiwagateway');
// Inisialisasi - Cukup API Key saja! Session auto-detect dari API Key
const wa = sdk.createClient({
apiKey: 'ak_live_abc123xyz789' // Dari Panel Andi WA Gateway
});
// Kirim pesan - Session auto-detect dari API Key!
await wa.sendMessage('628123456789', 'Halo dari SDK!');
// Kalau mau pakai session spesifik (opsional)
await wa.sendMessage('628123456789', 'Halo!', 'session-khusus');2. Kirim OTP (Plugin)
const sdk = require('andiwagateway');
const otp = sdk.createOtp({
apiKey: 'ak_live_abc123xyz789'
});
// Kirim OTP
const result = await otp.send('628123456789', {
appName: 'MyApp'
});
console.log('Kode OTP:', result.code); // Simpan ke database!
// Verifikasi
const isValid = otp.verify(inputUser, result.code);3. Webhook Handler (Terima Pesan)
const sdk = require('andiwagateway');
const webhook = sdk.createWebhook();
// Handler pesan masuk
webhook.onMessage(async (msg) => {
console.log('Dari:', msg.from);
console.log('Isi:', msg.body);
});
// Express middleware
app.post('/webhook/whatsapp', webhook.middleware());4. Fitur Baru v1.2.0! 🎉
Kirim Reaction Emoji
await wa.sendReaction('628123456789', 'MESSAGE_ID', '👍');Edit Pesan
await wa.editMessage('628123456789', 'MESSAGE_ID', 'Pesan yang sudah diedit');Hapus Pesan
await wa.deleteMessage('628123456789', 'MESSAGE_ID', true); // true = for everyoneForward Pesan
await wa.forwardMessage('628123456789', 'MESSAGE_ID', '628987654321');Kirim Polling/Voting
await wa.sendPoll('628123456789', 'Apa warna favoritmu?', ['Merah', 'Biru', 'Hijau']);Post Story/Status
// Post gambar
await wa.postStory('image', 'https://example.com/photo.jpg', 'Caption story');
// Post video
await wa.postStory('video', 'https://example.com/video.mp4', 'Video hari ini');Cek Nomor Valid
const result = await wa.checkNumber('628123456789');
console.log('Valid WhatsApp?', result.exists);📚 API Reference
createClient(config)
Membuat instance client utama.
const wa = sdk.createClient({
apiKey: 'your-api-key', // Required
sessionId: 'default-session', // Optional
baseUrl: 'https://custom-url.com' // Optional (override default)
});Methods:
| Method | Description |
|--------|-------------|
| wa.sendMessage(number, message, sessionId?) | Kirim pesan teks |
| wa.sendMedia(number, mediaUrl, caption?, sessionId?) | Kirim file/media |
| wa.getStatus(sessionId?) | Cek status session |
| wa.listSessions() | Daftar semua session |
| wa.registerWebhook(url, events?) | Register webhook URL |
| wa.sendReaction(number, messageId, reaction, sessionId?) | Kirim emoji reaction |
| wa.deleteMessage(number, messageId, forEveryone?, sessionId?) | Hapus pesan |
| wa.editMessage(number, messageId, newMessage, sessionId?) | Edit pesan |
| wa.forwardMessage(number, messageId, fromNumber, sessionId?) | Forward pesan |
| wa.sendPoll(number, question, options, allowMultiple?, sessionId?) | Kirim polling |
| wa.postStory(type, mediaUrl, caption?, sessionId?) | Post story/status |
| wa.checkNumber(number, sessionId?) | Cek nomor valid |
createOtp(config)
Plugin untuk kirim OTP.
const otp = sdk.createOtp({
apiKey: 'your-api-key',
sessionId: 'otp-session'
});Methods:
| Method | Description |
|--------|-------------|
| otp.generateCode(length?) | Generate kode random |
| otp.send(number, options?) | Kirim OTP |
| otp.sendWithTemplate(number, template, options?) | Kirim dengan template custom |
| otp.verify(input, stored) | Verifikasi kode |
createWebhook(config)
Handler untuk webhook.
const webhook = sdk.createWebhook({
secret: 'optional-secret' // Untuk verify signature
});Methods:
| Method | Description |
|--------|-------------|
| webhook.on(event, handler) | Register handler untuk event |
| webhook.onMessage(handler) | Handler khusus pesan masuk |
| webhook.middleware() | Express middleware |
| webhook.createRouter() | Express router instance |
💡 Contoh Lengkap
Lihat folder examples/:
basic-usage.js- Kirim pesan & mediaotp-plugin.js- Sistem verifikasi OTPexpress-webhook.js- Express server dengan webhookreaction-example.js- Kirim reaction emojistory-example.js- Post story/statuspoll-example.js- Kirim polling
🔧 Environment Variables
WA_GATEWAY_API_KEY=ak_live_abc123xyz789📞 Support
- Panel Admin: https://andi-wa-gateway.up.railway.app
- API Docs: Lihat dokumentasi di panel
- Version: v1.2.0 (Latest - 40+ Endpoints!)
📄 License
MIT
