Nexmo

Number Insight - Nexmo

Nexmo

Tap into vast amounts of real-time data about mobile numbers

Protect yourself from fraud and spam

  • Identity
  • Security

API reference on SwaggerHub API reference on Postman

Introduction

The Number Insight API provides details about the validity, reachability and roaming status of a phone number, as well as details on how to format the number properly in your application.

Conceptual model

Conceptual model

Definitions

Callback (WebHook)

A Callback or WebHook is a HTTP POST callback implemented by you, that can be called by another system when an event is triggered on that system to notify you. You will need to make the address of your webhook/callback known on the other system to make it work.

API workflow

API workflow

Features and constraints

Features

Feature   Basic   Standard   Advanced
Number format and origin   Y   Y   Y
Number type   N   Y   Y
Carrier and country   N   Y   Y
Ported   N   N   Y
IP match   N   N   Y
Validity   N   N   Y
Reachability   N   N   Y
Roaming status   N   N   Y
Roaming carrier and country   N   N   Y
US number caller name and type   N   Y   Y


Check the legislation in your country to ensure that you are allowed to save user roaming information.

Constraints

  • Only 1 phone number can be checked with each request
  • Phone numbers are in E.164 format

Getting started

Setting up your third party accounts

Make sure you have a registered account on the API Store and created an application on the portal, to receive the associated client ID and secret. These are neccessary to request an access token. You will receive these after your app is approved on te API Store.

Authentication

OAuth 2.0

For accessing and/or manipulating the resources, the client application (your application) needs to be granted permission to do so. The OAuth 2.0 standard defines a protocol that allows such third-party authorization through the use of access tokens. Access tokens are central in the protocol: those tokens, in the form of strings, are delivered by an authorization server (our authentication server) and they enable the client application to securely access protected data on behalf of the resource owner (the end-user). We use Client Credentials Grant which means the application makes the request to the authentication service by sending authorization credentials and the service responds with an access token among other useful information.

Get Access Token

Copy your app's credentials (Consumer Key & Consumer Secret) to be used in the Authentication requests below.

Authentication in SwaggerHub

  1. Upon loading completed within SwaggerHub, look top right for the Authorize button and click it.
  2. In the form, fill in client_id and client_secret fields, using your app's credentials.
  3. Click Authorize.
  4. Now you are authorized to issue the requests provided.

Authentication in Postman

  1. Select Get Access Token from the collection.
  2. Make sure the right Environment corresponding to the API is selected.
  3. Edit the environment variables client_id and client_secret, using your app's credentials.
  4. Check the response code and message.
  5. Press the Send button to get the access token.
  6. Now you are authorized to issue the other requests in the collection.

The authorization service returns a JSON message that contains the access_token field.

{
    "refresh_token_expires_in": "0",
    "api_product_list": "[xxxxxxx]",
    "api_product_list_json": [
        " xxxxxxx"
    ],
    "organization_name": "kpn",
    "developer_email": "demo123@kpn.com",
    "token_type": "Bearer",
    "issued_at": "1521039195424",
    "client_id": "APP_CONSUMER_KEY",
    "access_token": "haf2SDl07E9N7RluNQ4kJ1TkGgso",
    "application_name": "6e38ed2d-48b1-4362-97d6-04254065d79c",
    "scope": "",
    "expires_in": "3599",
    "refresh_count": "0",
    "status": "approved"
}

How to...

Use Number Insight Basic

You can use Nexmo's Number Insight Basic API to retrieve local and international representations of a phone number by doing semantic checks on the number you submit. This can help you normalize and consistently print numbers in your user interface and give you information to help you decide whether you accept the phone number entered by your user, or ask them to check and correct it.

The Number Insight Basic API is a free synchronous, easy-to-use RESTful web service. For any phone number you can:

  • Retrieve the international and local format.
  • Know the country where the number is registered.

SwaggerHub:

  1. Select POST /{level}.
  2. Click Try it out.
  3. In the drop down box level, select basic
  4. In the number field, fill out the phone number.
  5. Click Execute.
  6. Check the response code and message.

Postman:

  1. Select (POST) Number Insight - Basic.
  2. Click the Body section of the request and provide value for the number key.
  3. Click Send.
  4. Check the response code and message.

Use Number Insight Standard

You can use Nexmo's Number Insight Standard API to retrieve a user's landline or mobile number, including checking to see if it's registered to an operator. This can help you verify that a phone number is real and give you information on how to format the number.

The Number Insight Standard API is a synchronous, easy-to-use RESTful web service. For any phone number you can:

  • Retrieve the international and local format.
  • Know the country where the number is registered.
  • Detect the line type (mobile/landline/virtual number/premium/toll-free)
  • Detect mobile country code (MCC) and mobile network code (MNC)
  • Detect if the number is ported
  • Identify caller name (USA only)
  • Check if phone number is reachable

SwaggerHub:

  1. Select POST /{level}.
  2. Click Try it out.
  3. In the drop down box level, select standard
  4. In the number field, fill out the phone number.
  5. Click Execute.
  6. Check the response code and message.

Postman:

  1. Select (POST) Number Insight - Standard.
  2. Click the Body section of the request and provide value for the number key.
  3. Click Send.
  4. Check the response code and message.

Use Number Insight Advanced

You can use Nexmo's Number Insight Advanced API to retrieve a user's landline or mobile number, including checking to see if it's registered to an operator. This can help you verify that a phone number is real and give you information on how to format the number.

The Number Insight Advanced Async API is a synchronous, easy-to-use RESTful web service. For any phone number you can:

  • Retrieve the international and local format.
  • Know the country where the number is registered.
  • Detect the line type (mobile/landline/virtual number/premium/toll-free)
  • Detect mobile country code (MCC) and mobile network code (MNC)
  • Detect if the number is ported
  • Identify caller name (USA only) - see the CNAM guide for details
  • Identify network when roaming
  • Confirm that user's IP address is in the same location as their mobile phone

Be aware that the Advanced API does not give any information about landlines that has not already been given by the Standard API. For number insights about landlines, you should use the Standard API.

SwaggerHub:

  1. Select POST /{level}.
  2. Click Try it out.
  3. In the drop down box level, select advanced
  4. In the number field, fill out the phone number.
  5. Click Execute.
  6. Check the response code and message.

Postman:

  1. Select (POST) Number Insight - Advanced.
  2. Click the Body section of the request and provide value for the number key.
  3. Click Send.
  4. Check the response code and message.

Use Number Insight Advanced Async

You can use Nexmo's Number Insight Async API to retrieve a user's landline or mobile number, including checking to see if it's registered to an operator. This can help you verify that a phone number is real and give you information on how to format the number.

The Number Insight Advanced Async API is an asynchronous web service that returns data to a webhook. For any phone number you can:

  • Retrieve the international and local format.
  • Know the country where the number is registered.
  • Line type detection (mobile/landline/virtual number/premium/toll-free)
  • Detect mobile country code (MCC) and mobile network code (MNC)
  • Detect if the number is ported
  • Identify caller name (USA only)
  • Identify network when roaming
  • Confirm that user's IP address is in the same location as their mobile phone

Be aware that the Advanced API does not give any information about landlines that has not already been given by the Standard API. For number insights about landlines, you should use the Standard API.

SwaggerHub:

  1. Select POST /advanced/async.
  2. Click Try it out.
  3. In the number field, fill out the phone number.
  4. In the callback field, provide the URL of your webhook.
  5. Click Execute.
  6. Check the response code and message.

Postman:

  1. Select (POST) Number Insight Advanced - Async.
  2. Click the Body section of the request and provide values for the number and callback key.
  3. Click Send.
  4. Check the response code and message.

Result example:

{
  "status": 0,
  "status_message": "Success",
  "lookup_outcome": 0,
  "lookup_outcome_message": "Success",
  "request_id": "55a7ed8e-ba3f-4730-8b5e-c2e787cbb2b2",
  "international_format_number": "447700900000",
  "national_format_number": "07700 900000",
  "country_code": "GB",
  "country_code_iso3": "GBR",
  "country_name": "United Kingdom",
  "country_prefix": "44",
  "request_price": "0.03000000",
  "remaining_balance": "1.97",
  "current_carrier": {
    "network_code": "23410",
    "name": "Telefonica UK Limited",
    "country": "GB",
    "network_type": "mobile"
  },
  "original_carrier": {
    "network_code": "23410",
    "name": "Telefonica UK Limited",
    "country": "GB",
    "network_type": "mobile"
  },
  "valid_number": "valid",
  "reachable": "reachable",
  "ported": "not_ported",
  "roaming": {
    "status": "not_roaming"
  }
}

Return codes

Code   Description
200   Success
201   Created
202   Accepted
302   Found. Link in location header
400   Bad request
401   Unauthorized
403   Forbidden
404   Not found
405   Method not allowed
412   Precondition failed
429   Too many requests
500   Internal server error
502   Bad gateway
503   Service unavailable

API versions

Version   Description
1.0   Initial version