Nexmo Number Insight API

API reference on SwaggerHub

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

Authentication

To authenticate you'll need to request an access token. Use your API Store app's credentials (Consumer Key and Consumer Secret) to make an authentication request. The authorization service returns a JSON message that contains the access_token field.

Use one of the following 3 options:

cURL

Execute below cURL command to receive an access token. Replace APP_CONSUMER_KEY and APP_CONSUMER_SECRET with your app's credentials.

curl -X POST \
 'https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials' \
 -H 'content-type: application/x-www-form-urlencoded' \
 -d 'client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET'

If you are using cURL for Windows, please use the command below instead.

curl -X POST "https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials" -H "content-type: application/x-www-form-urlencoded" -d "client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET"

The authentication 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": "6e38edxxxxxxxxxxxxxxxx4065d79c",
    "scope": "",
    "expires_in": "3599",
    "refresh_count": "0",
    "status": "approved"
}

SwaggerHub

  1. Click on the Authorize button on the top right.
  2. In the form, fill in client_id and client_secret, using your app's credentials.
  3. Click Authorize.

Postman

When using Postman, you will have to import the Swagger file into a Postman collection as follows:

  1. Open the API reference on SwaggerHub.
  2. On the top right, click Export, click Download API and click 'YAML Unresolved'.
  3. In Postman from the menu click File and click Import... Choose the YAML file you downloaded in the previous step. A new collection will be added.
  4. Select Get Access Token from the collection.
  5. Make sure the right environment is selected, corresponding to the API.
  6. Edit the environment variables client_id and client_secret, using your app's credentials.
  7. Check the response code and message.
  8. Press the Send button to get an access token.

Note: Request variables are no longer linked to an environment, but to the collection.

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