To implement SMSVerifier API in a Node.js app for WhatsApp verification, register at SMSVerifier, use your API key with HTTP requests (e.g., axios) to rent a WhatsApp number, then poll the API to retrieve OTP SMS messages for verification.
Overview of SMSVerifier API for WhatsApp
SMSVerifier.com offers a robust API for renting virtual phone numbers that receive SMS messages for verification purposes. Specifically for WhatsApp, these numbers allow you to receive one-time passwords (OTPs) sent during account registration or login processes.
The API supports purchasing numbers, checking their status, retrieving SMS messages, and releasing or extending the rental period. The process is designed to be fully automated, enabling seamless integration with backend Node.js applications.
WhatsApp verification requires a valid phone number that can receive SMS. SMSVerifier provides virtual numbers from multiple countries optimized for WhatsApp OTP reception.
Setting Up Your Node.js Environment
Before coding, ensure you have Node.js installed (v12 or higher recommended). You will also need to register an account at SMSVerifier.com to get your personal API key.
Use npm or yarn to install an HTTP client library. We recommend axios for its ease of use and promise support:
npm install axios
Your API key will authenticate requests to SMSVerifier's API endpoint:
https://smsverifier.com/stubs/handler_api.php
Store your API key securely using environment variables (e.g., process.env.SMSVERIFIER_API_KEY) instead of hardcoding it in your source code.
Key API Endpoints and Workflow
The basic workflow to verify WhatsApp via SMSVerifier API includes these steps:
- Get your balance: Check available funds to ensure you can purchase numbers.
- Request a WhatsApp virtual number: Specify the service parameter as "whatsapp" and optionally select a country.
- Poll for SMS messages: Wait and retrieve OTP codes sent to the rented number.
- Release or extend the number: Either free up the number or keep it for multiple verifications.
Each API call requires your api_key and an action parameter like getNumber, getStatus, or getSMS. Responses are typically JSON or plain text containing status codes and message content.
Node.js Code Sample for WhatsApp OTP
Below is a minimal example demonstrating how to purchase a WhatsApp number and retrieve the OTP SMS using axios:
const axios = require('axios');
const API_KEY = process.env.SMSVERIFIER_API_KEY; // Set your API key in env variables
// Step 1: Get balance
async function getBalance() {
const res = await axios.get('https://smsverifier.com/stubs/handler_api.php', {
params: { api_key: API_KEY, action: 'getBalance' }
});
console.log('Balance:', res.data);
return parseFloat(res.data);
}
// Step 2: Get WhatsApp number
async function getWhatsAppNumber(country = 'us') {
const res = await axios.get('https://smsverifier.com/stubs/handler_api.php', {
params: { api_key: API_KEY, action: 'getNumber', service: 'whatsapp', country }
});
if (res.data.startsWith('ACCESS_NUMBER')) {
const parts = res.data.split(':');
const id = parts[1];
const phone = parts[2];
console.log(\`Number rented: \${phone} (ID: \${id})\`);
return { id, phone };
}
throw new Error('Failed to get number: ' + res.data);
}
// Step 3: Poll for SMS OTP
async function waitForSms(id, timeout = 600000, interval = 5000) {
const start = Date.now();
while (Date.now() - start < timeout) {
const res = await axios.get('https://smsverifier.com/stubs/handler_api.php', {
params: { api_key: API_KEY, action: 'getStatus', id }
});
if (res.data.startsWith('STATUS_OK')) {
const smsParts = res.data.split(':');
const smsText = smsParts.slice(1).join(':').trim();
console.log('Received SMS:', smsText);
return smsText;
}
console.log('Waiting for SMS...');
await new Promise(r => setTimeout(r, interval));
}
throw new Error('Timeout waiting for SMS');
}
// Example usage
(async () => {
try {
const balance = await getBalance();
if (balance < 1) {
throw new Error('Insufficient balance');
}
const { id, phone } = await getWhatsAppNumber('us');
console.log('Enter this number into WhatsApp to receive your OTP:', phone);
const smsText = await waitForSms(id);
// Extract OTP code from smsText if needed
console.log('OTP:', smsText);
} catch (e) {
console.error('Error:', e.message);
}
})();
Use regular expressions to parse OTP codes from received SMS text automatically to streamline verification.
Error Handling and Best Practices
When integrating the API, keep these in mind:
- Always check the API response status codes and messages for errors.
- Implement retries with backoff when polling for SMS to avoid hitting rate limits.
- If no SMS arrives within 20 minutes, the API supports automatic refunds — handle this gracefully in your app.
- Secure your API key and never expose it in client-side code.
Don't hardcode phone numbers or OTPs; always dynamically retrieve and validate them to avoid verification failures.
Pricing and Country Selection
WhatsApp virtual numbers vary in price and availability by country. SMSVerifier offers numbers from over 200 countries. Popular countries for WhatsApp verification include the
United States,
United Kingdom, and
India.
Prices generally start from $0.20 per SMS, but WhatsApp numbers can be slightly higher due to demand and provider costs. Check the pricing page for up-to-date rates.
Fast delivery
WhatsApp OTPs usually arrive within 20-60 seconds after purchase.
Global coverage
Choose from numbers in 200+ countries tailored for WhatsApp.
Flexible payments
Pay via PayPal, card, or cryptocurrencies like BTC, ETH, USDT.
Frequently asked questions
What is the SMSVerifier API and how does it help with WhatsApp verification?
How do I get started with SMSVerifier API in a Node.js application?
What Node.js libraries are recommended for calling the SMSVerifier API?
How do I handle errors and SMS delivery failures in the API integration?
Can I automate WhatsApp number purchase and OTP retrieval fully?
Is there example code for Node.js usage with SMSVerifier API?
Are there country or pricing considerations for WhatsApp numbers?
Ready to receive your first WhatsApp OTP?
Register in 30 seconds — no card required, pay-as-you-go from $0.20 per SMS.
Get a WhatsApp number