Norma Number Insight

A partir del 4 de febrero de 2027, Vonage dejará de ofrecer el servicio «Vonage Number Insights». Para garantizar una asistencia ininterrumpida y ofrecer una solución más escalable y preparada para el futuro, le recomendamos que migre a nuestra oferta mejorada: API de información de identidad de Vonage. La API «Vonage Identity Insights» agrupa varios conjuntos de datos relacionados con números de teléfono en una única API flexible, lo que te permite solicitar información en tiempo real sobre un número de teléfono y obtener cualquier combinación de datos —como el formato del número, los detalles del operador, el cambio de tarjeta SIM y la coincidencia de abonados— en una sola llamada.

Por favor, revise el Guía de transición Number Insightsque ofrece información detallada sobre las diferencias entre las API, los cambios necesarios y las mejores prácticas para una transición sin problemas.

La Number Insight API estándar proporciona toda la información procedente de la API básica de Number Insight junto con los siguientes datos adicionales:

  • El tipo de línea (móvil/fijo/número virtual/premium/gratuito)
  • Indicativo móvil de país (MCC) e indicativo móvil de red (MNC)
  • El nombre de la persona que llama (sólo EE.UU.)

Utiliza esta información para determinar cuál es el mejor tipo de comunicación para un número (SMS o llamada) y bloquear los números virtuales.

Antes de intentar ejecutar los ejemplos de código, sustituye los marcadores de posición de las variables:

ClaveDescripción
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

INSIGHT_NUMBER

The number you want to retrieve insight information for.

Escriba el código

Añada lo siguiente a ni-standard.sh:

curl \
  -u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
  "https://api.nexmo.com/ni/standard/json?number=$INSIGHT_NUMBER"

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

sh ni-standard.sh

Requisitos previos

npm install @vonage/server-sdk

Crea un archivo llamado ni-standard.js y añade el siguiente código:

const { Vonage } = require('@vonage/server-sdk');

const vonage = new Vonage({
  apiKey: VONAGE_API_KEY,
  apiSecret: VONAGE_API_SECRET,
});

Ver fuente completa

Escriba el código

Añada lo siguiente a ni-standard.js:

vonage.numberInsights.standardLookup(INSIGHT_NUMBER)
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

node ni-standard.js

Requisitos previos

Añada lo siguiente a build.gradle:

implementation 'com.vonage:server-sdk-kotlin:2.1.1'

Crea un archivo llamado StandardInsight y añade el siguiente código al método main:

val client = Vonage {
    apiKey(VONAGE_API_KEY)
    apiSecret(VONAGE_API_SECRET)
}

Ver fuente completa

Escriba el código

Añada lo siguiente al método main del archivo StandardInsight:

val response = client.numberInsight.standard(INSIGHT_NUMBER)
println(response)

Ver fuente completa

Ejecute su código

Podemos utilizar el plugin aplicación para Gradle para simplificar la ejecución de nuestra aplicación. Actualiza tu build.gradle con lo siguiente:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

Ejecute el siguiente comando gradle para ejecutar su aplicación, sustituyendo com.vonage.quickstart.kt.numberinsight por el paquete que contiene StandardInsight:

gradle run -Pmain=com.vonage.quickstart.kt.numberinsight.StandardInsight

Requisitos previos

Añada lo siguiente a build.gradle:

implementation 'com.vonage:server-sdk:9.3.1'

Crea un archivo llamado StandardInsight y añade el siguiente código al método main:

VonageClient client = VonageClient.builder()
        .apiKey(VONAGE_API_KEY)
        .apiSecret(VONAGE_API_SECRET)
        .build();

Ver fuente completa

Escriba el código

Añada lo siguiente al método main del archivo StandardInsight:

StandardInsightResponse response = client.getInsightClient().getStandardNumberInsight(INSIGHT_NUMBER);

System.out.println("BASIC INFO:");
System.out.println("International format: " + response.getInternationalFormatNumber());
System.out.println("National format: " + response.getNationalFormatNumber());
System.out.println("Country: " + response.getCountryName() +
        " (" + response.getCountryCodeIso3() + ", +" + response.getCountryPrefix() + ")"
);

System.out.println();
System.out.println("CARRIER INFO:");
System.out.println("Current carrier: " + response.getCurrentCarrier().getName());
System.out.println("Original carrier: " + response.getOriginalCarrier().getName());

Ver fuente completa

Ejecute su código

Podemos utilizar el plugin aplicación para Gradle para simplificar la ejecución de nuestra aplicación. Actualiza tu build.gradle con lo siguiente:

apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''

Ejecute el siguiente comando gradle para ejecutar su aplicación, sustituyendo com.vonage.quickstart.insight por el paquete que contiene StandardInsight:

gradle run -Pmain=com.vonage.quickstart.insight.StandardInsight

Requisitos previos

Install-Package Vonage

Crea un archivo llamado StandardInsights.cs y añade el siguiente código:

using Vonage;
using Vonage.NumberInsights;
using Vonage.Request;

Ver fuente completa

Añada lo siguiente a StandardInsights.cs:


var creds = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET);

Ver fuente completa

Escriba el código

Añada lo siguiente a StandardInsights.cs:


var request = new StandardNumberInsightRequest() { Number = INSIGHT_NUMBER};

Ver fuente completa

Requisitos previos

composer require vonage/client

Escriba el código

Añada lo siguiente a standard.php:

$basic  = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client($basic);

$insights = $client->insights()->standard(INSIGHT_NUMBER);

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

php standard.php

Requisitos previos

pip install vonage python-dotenv

Escriba el código

Añada lo siguiente a ni-standard.py:

from vonage import Auth, Vonage
from vonage_number_insight import (StandardInsightRequest,
                                   StandardInsightResponse)

client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))

insight: StandardInsightResponse = client.number_insight.get_standard_info(
    StandardInsightRequest(number=INSIGHT_NUMBER)
)
pprint(insight)

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

python number-insight/ni-standard.py

Requisitos previos

gem install vonage

Crea un archivo llamado ni-standard.rb y añade el siguiente código:

client = Vonage::Client.new(
  api_key: VONAGE_API_KEY,
  api_secret: VONAGE_API_SECRET
)

Ver fuente completa

Escriba el código

Añada lo siguiente a ni-standard.rb:

insight = client.number_insight.standard(
  number: INSIGHT_NUMBER
)

puts insight.inspect

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

ruby ni-standard.rb

La respuesta de la API contiene los siguientes datos:

{
    "status": 0,
    "status_message": "Success",
    "request_id": "e98e0dfb-c485-491b-8d2a-283f35e21d04",
    "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.00500000",
    "remaining_balance": "10.000000",
    "current_carrier": {
        "network_code": "23420",
        "name": "Hutchison 3G Ltd",
        "country": "GB",
        "network_type": "mobile"
    },
    "original_carrier": {
        "network_code": "23410",
        "name": "Telefonica UK Limited",
        "country": "GB",
        "network_type": "mobile"
    },
    "ported": "assumed_ported",
    "roaming": { "status": "unknown" }
}

Para obtener una descripción de cada campo devuelto y ver todos los valores posibles, consulte la página Documentación de la Number Insight API