There are three steps to integrating the Phone Verification API into your Node.js project.
1. Create an account.
Sign up for an Esendex account. When you register you will receive a license key. You will need this to use the API.
2. Install Node.js.
Install Node.js if it is not on your computer already. To check, run this command in your terminal: node -v
PS C:> node -v
v18.16.0
3. Verify a phone number.
Install a SOAP client for Node.js. Run this command in your terminal: npm install soap
Create a new JavaScript module file. Let’s call it demo.mjs.
You can use the CheckPhoneNumber
method to verify a phone number. Add the displayed code to your new file.
Replace the LicenseKey
value with your account’s license key.
import soap from 'soap';
const url = 'https://ws.esendex.us/phoneverify/phoneverify.asmx?wsdl';
const args = {
'PhoneNumber': '17575449510',
'LicenseKey': '00000000-0000-0000-0000-000000000000'
};
const client = await soap.createClientAsync(url);
const result = await client.CheckPhoneNumberAsync(args);
console.log(result[0]);
Run the project in your terminal with this command: node demo.mjs
. The program will display the results of the phone number verification.
PS C:JsDemo> node demo.mjs
{
CheckPhoneNumberResult: {
Company: 'LEVEL 3 COMMUNICATIONS, LLC -',
Valid: true,
Use: 'Assigned to a code holder for normal use.',
State: 'VA',
RC: 'PARKSLEY',
OCN: '8825',
OriginalNumber: '17575449510',
CleanNumber: '7575449510',
SwitchName: 'NORFOLK',
SwitchType: '',
Country: 'United States',
CLLI: 'CHSKVAAYDS0',
PrefixType: 'CLEC - (Competitive Local Exchange Carrier)',
LATA: '252',
sms: 'CLEC - (Competitive Local Exchange Carrier)',
Email: '',
AssignDate: 'Unknown',
TelecomCity: 'Chesapeake',
TelecomCounty: '',
TelecomState: 'VA',
TelecomZip: '23324',
TimeZone: 'EST',
Lat: '',
Long: '',
Wireless: false,
LRN: '7576559199'
}
}