Contact Us

Find out the details behind a phone number using Lookups API and Node.js

If you are using the Messaging API to send bulk messages, ensuring you are sending to valid mobile phone numbers will help to maximise your Return on Investment (ROI). You can use this API to checking the validity, type and carrier records of the numbers in your database.

To check phone number validity, you call the Lookups API with the phone number you’d like to check. Our Lookups API will then identify legitimate numbers, their carriers, country of origin and phone type (mobile or landline). Finally, it will send a response back to you. Let’s take look at how you can look up a number using the Lookups API.

Prerequisites

We’ll be using Node.js for this guide but you can use Java, C# or any of our other SDKs instead. 

Step 1 – Install and setup a Node.js project

     npm init

Step 3 – Install the Lookups Node.js SDK

     npm install messagemedia-lookups-sdk

Step 4 – Adding the magical bits

const sdk = require('messagemedia-lookups-sdk');

sdk.Configuration.basicAuthUserName = "API_KEY"; 
sdk.Configuration.basicAuthPassword = "API_SECRET";

var controller = sdk.LookupsController;

var phoneNumber = "YOUR_MOBILE_NUMBER";
var options = 'carrier,type';

controller.getLookupAPhoneNumber(phoneNumber, options, function(error, response, context) {
  console.log(response)
});

Don’t forget to replace YOUR_MOBILE_NUMBER with your desired mobile number and also YOUR_API_KEY and API_SECRET with the ones you received when you signed up for the Developer portal in Step 1.

Step 5 – Running the script

node index.js

And that’s it. That’s how you look up a phone number. Find out more in-depth information about the Lookups API, view the documentation.

Lookups can be quite effective if used for the right use cases. In general, getting better acquainted with the numbers in your contact database carries a host of benefits including minimised costs and maximised ROI. You can find the Lookups API in your favourite language on our Github repository.