Numbersインサイト・ベーシック
2027年2月4日をもって、VonageはVonage Number Insightsを終了いたします。継続的なサポートを確保し、よりスケーラブルで将来性のあるソリューションを提供するため、当社の強化されたソリューションへの移行をお勧めします: Vonage Identity Insights API.Vonage Identity Insight APIは、複数の電話番号関連データセットを1つの柔軟なAPIに統合し、電話番号に関するリアルタイムの情報を要求したり、番号のフォーマット、キャリアの詳細、SIMスワップ、加入者照合などのインサイトを1回の呼び出しで自由に組み合わせて取得できるようにします。
をご確認ください。 Numbersインサイト移行ガイドAPIの相違点、必要な変更点、スムーズな移行のためのベストプラクティスに関する詳細なガイダンスを提供しています。
Vonage Number Insight Basic APIを使用して決定します:
- ナンバーが登録されている国
- そのNumbersの国内外での表現
これにより、ユーザーのロケールに合った正しい形式でNumbersを表示することができます。
コード例を実行する前に、変数のプレースホルダーを置き換えてください:
| キー | 説明 |
|---|---|
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. |
Write the code
Add the following to ni-basic.sh:
curl "https://api.nexmo.com/ni/basic/json?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&number=$INSIGHT_NUMBER"
Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdkCreate a file named ni-basic.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
});Write the code
Add the following to ni-basic.js:
vonage.numberInsights.basicLookup(INSIGHT_NUMBER)
.then((result) => console.log(result))
.catch((error) => console.error(error));Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named BasicInsight and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the BasicInsight class:
val response = client.numberInsight.basic(INSIGHT_NUMBER)
println(response)Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.numberinsight with the package containing BasicInsight:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named BasicInsight and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the BasicInsight class:
BasicInsightResponse response = client.getInsightClient().getBasicNumberInsight(INSIGHT_NUMBER);
System.out.println("International format: " + response.getInternationalFormatNumber());
System.out.println("National format: " + response.getNationalFormatNumber());
System.out.println("Country: " + response.getCountryName() +
" (" + response.getCountryCodeIso3() + ", +" + response.getCountryPrefix() + ")"
);Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.insight with the package containing BasicInsight:
Prerequisites
Install-Package VonageCreate a file named BasicInsights.cs and add the following code:
using Vonage;
using Vonage.NumberInsights;
using Vonage.Request;Add the following to BasicInsights.cs:
var creds = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET);Write the code
Add the following to BasicInsights.cs:
var request = new BasicNumberInsightRequest() { Number = INSIGHT_NUMBER };Prerequisites
composer require vonage/clientWrite the code
Add the following to basic.php:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client($basic);
$insights = $client->insights()->basic(INSIGHT_NUMBER);Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to ni-basic.py:
from vonage import Auth, Vonage
from vonage_number_insight import BasicInsightRequest, BasicInsightResponse
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
insight: BasicInsightResponse = client.number_insight.get_basic_info(
BasicInsightRequest(number=INSIGHT_NUMBER)
)
pprint(insight)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named ni-basic.rb and add the following code:
Run your code
Save this file to your machine and run it:
APIからのレスポンスには以下のデータが含まれている:
{
"status": 0,
"status_message": "Success",
"request_id": "fcb1e9a2-db9c-4ea2-84be-4e60da45e187",
"international_format_number": "447700900000",
"national_format_number": "07700 900000",
"country_code": "GB",
"country_code_iso3": "GBR",
"country_name": "United Kingdom",
"country_prefix": "44"
}
返される各フィールドの説明と、可能なすべての値については Numbers Insight API ドキュメント