Getting Started with Nexmo Number Insight APIs and ASP.NET

Published May 22, 2018 by Rabeb Othmani

Nexmo’s Number Insight API is perfect for real-time validation of user input that could potentially protect your apps from fraud and spam and help you get details about a phone number such as validity, reachability and roaming status.
You can use also the Number Insight API to validate that a phone number is formatted properly. This is very useful especially if you are using our other APIs.

Number insight is available with three levels:

  • Basic: used to format numbers and display them in international and local representations.
  • Standard: best used to identify number type to decide between SMS and Voice; block virtual numbers.
  • Advanced: best used to determine risk based on numbers.

The advanced API is also available asynchronously as well as synchronously.

You can check the full list of what’s available on each level on the Number Insight documentation.

For the sake of readability and getting straight to the point, I’m going to post this tutorial as a series of step-by-step articles instead of one long post. In each article, we will see how to use one of the three levels of the Number Insight API with an ASP.NET app. So let’s get started!

Prerequisites

  • Visual Studio 2017.
  • Nexmo Account. You can sign up here
  • A project set up for this tutorial series which you can find on Github.
  • Optional: Nexmo CLI.

Configuration

We will be showcasing how to use Number Insight API with an ASP.NET Web Application. So the first step is to create an ASP.NET project.

  • Launch Visual Studio and create a new ASP.NET Web Application (.NET Framework) project.


  • Select the MVC Template and ensure the Authentication type is set to No Authentication. Click OK to create the project.


  • Install the Nexmo C# Client Library via the NuGet Package Manager Console.

Voila, we now have the template for the ASP.NET web app project and we are ready to write some code.

Getting some number insights

Now that we set up the project, let’s see how to get some insights.
Under the Controllers folder, create a new controller called NumberInsightController.cs. In the constructor, instantiate a Nexmo Client and authenticate with the API using your API key and secret. Those can be found on your Nexmo dashboard.

Then under the views folder, create a new folder called NumberInsight. This folder will contain all Number Insight views we will need.
We will need an Index.cshtml view to allow the navigation to the other views.

Recap

In this first article of the guideline, we:

  • setup the ASP.NET project.
  • installed the Nexmo C# Client Library.
  • prepared the main skeleton of our project.

In the second article, we will learn how to get Basic Insights.

Leave a Reply

Your email address will not be published.