We’re welcoming two best in class authentication APIs from Nexmo to the RapidAPI Marketplace – the Verify API and Number Insight API. We’ll first cover the functionality of the Number Insight API, which allows users to retrieve intelligence on any phone number in the world. We’ll then cover the Verify API, which provides simple 2 step authentication via API.
What is Possible with Nexmo’s Number Insight API?
Nexmo’s Number Insight API provides details about the validity, reachability and roaming status of a phone number, as well as give you details on how to format the number properly in your application.
There are three levels of Number Insight API available: Basic, Standard, and Advanced. The basic option will let you retrieve international and local format as well as country recognition. The next level up, Standard, will also detect if the number is ported and Identify caller name. Lastly, the advanced option will let you check if the phone number is reachable, identify network when roaming and confirm a user’s IP address.
How to Use Nexmo’s Number Insight API?
Nexmo has made it extremely easy to get number intelligence of a phone number through a single API call. All you need to do is enter in the phone number of the desired user and optionally other parameters like country, ip and cnam (indicates if the name of the phone number’s owner should be retrieved) can be added. Keep in mind the Basic plan is restricted to only the phone number parameter, while both standard and advanced plans allow for optional parameters.
Similar to all of the APIs listed on RapidAPI, we provide an easy to use code snippet in any of your favorite programming languages to make the connection process quick and easy! This is what the NodeJS code snippet will look like:
var unirest = require(‘unirest’); unirest.post("https://nexmo-nexmo-number-insight-v1.p.mashape.com/basic/json?number=<required>") .header("X-Mashape-Key", "********************************") .header("Content-Type", "application/x-www-form-urlencoded") .end(function (result) { console.log(result.status, result.headers, result.body); });
As for pricing, access to the Basic Number Insight endpoint is free and unlimited. But for the Standard and Advanced Nexmo Number Insight, your account will be charged $ 0.006 for each request to the Standard Requests endpoint and $ 0.036 for each request to the Advanced Requests endpoint.
Now let’s take a look at the Verify API.
What Is Possible with Nexmo’s Verify API?
The Verify API allows you to send a PIN by SMS and phone to prove a user can be contacted at a specific phone number.
Use cases include:
- Spam protection – prevent spammers from mass-creating new accounts (etc.)
- Hack protection – if you detect suspicious or significant activities, validate that the person using a phone number owns it
- Reaching users – ensuring you have the correct phone number makes it easy to contact users when you need to
- Two-factor authentication
How to Use Nexmo’s SMS Verify API?
To start the process of verifying a user, we need to send a request to the Send Verification Code function that includes two variables (phoneNumber and brand). The phoneNumber parameter is the number of your end user who needs to receive a verification code. The brand parameter is the name of the company or application that the recipient of the SMS is expecting to receive a verification code from.
This is what the NodeJS code snippet to send that request will look like:
var unirest = require(‘unirest’); unirest.post("https://nexmo-nexmo-sms-verify-v1.p.mashape.com/send-verification-code?brand=RapidAPI&phoneNumber=1**********") .header("X-Mashape-Key", "********************************") .header("Content-Type", "application/x-www-form-urlencoded") .end(function (result) { console.log(result.status, result.headers, result.body); });
In the response of this API request, you’ll receive a value called ‘request_id’. You’ll need to make sure that you save this value to be used when your user attempts to enter their verification code to your application.
Now that the verification code sent to the user’s phone, we then want to check to confirm if the user has received and entered their code correctly. Your application should now show a prompt which allows the user to enter the PIN they have received. Once the user receives the PIN, you should send it back to Nexmo using the Check Verification Code function. With this function, you’ll need to provide the code they enter and the request_id from the first step. In the response of this API, it will tell you whether it was the correct code or not.
The NodeJS code snippet for this part will look like this:
var unirest = require(‘unirest’); unirest.get("https://nexmo-nexmo-sms-verify-v1.p.mashape.com/check-verification-code?code=<required>&request_id=<required>") .header("X-Mashape-Key", "******************") .end(function (result) { console.log(result.status, result.headers, result.body); });
Nexmo’s Verify API Pricing (shown below) – uses a crediting system to track the cost of your usage. There are 4 different tiered pricing plans that grant your account an allotted number of credits per month. US and India prices are 361 credits ($.0361) per successful verification while all other countries are 1205 ($.1205) per verification.
We think you’ll find both APIs super useful for many applications and can’t wait to hear how you like them! Hit us up with any feedback or questions – support@rapidapi.com.
Summary: Nexmo APIs
API | Functions | API Pricing | Endpoints |
---|---|---|---|
Nexmo SMS Verify API | Spam protection, hack protection, reaching users, and two-factor authentication. | Basic - $0.00 for 1,000 Monthly API Calls Pro - $10.00 for 100,000 Monthly API Calls Ultra - $50.00 for 500,000 API Calls Mega - $250.00 for 2,500,000 API Calls | 2 |
Nexmo Number Insight API | Phone number intelligence. | Basic Requests - Unlimited Standard Requests - $0.006 per API Call Advanced Requests - $0.036 per API Call | 3 |
Amitava Roy Chowdhoury says
What is the Custom Message character limit for Nexmo message API