Numbersインサイトアドバンス(同期式)

2027年2月4日をもって、VonageはVonage Number Insightsを終了いたします。継続的なサポートを確保し、よりスケーラブルで将来性のあるソリューションを提供するため、当社の強化されたソリューションへの移行をお勧めします: Vonage Identity Insights API.Vonage Identity Insight APIは、複数の電話番号関連データセットを1つの柔軟なAPIに統合し、電話番号に関するリアルタイムの情報を要求したり、番号のフォーマット、キャリアの詳細、SIMスワップ、加入者照合などのインサイトを1回の呼び出しで自由に組み合わせて取得できるようにします。

をご確認ください。 Numbersインサイト移行ガイドAPIの相違点、必要な変更点、スムーズな移行のためのベストプラクティスに関する詳細なガイダンスを提供しています。

このコードスニペットは、Number Insight Advanced APIを同期的に使用する方法を示しています。

:Vonageはこの方法を推奨していません。タイムアウトが発生する可能性があるからです。ほとんどの場合 非同期呼び出し をNumber Insight APIに追加した。

コード例を実行する前に、変数のプレースホルダーを置き換えてください:

キー説明
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.

REAL_TIME_DATA

An optional flag to determine if you want real time data back in the response.

Write the code

Add the following to ni-advanced.sh:

source "../config.sh"

curl "https://api.nexmo.com/ni/advanced/json?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&number=$INSIGHT_NUMBER"

View full source

Run your code

Save this file to your machine and run it:

sh ni-advanced.sh

APIからのレスポンスには以下のデータが含まれている:

{
    "status": 0,
    "status_message": "Success",
    "lookup_outcome": 0,
    "lookup_outcome_message": "Success",
    "request_id": "75fa272e-4743-43f1-995e-a684901222d6",
    "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": "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"
    },
    "valid_number": "valid",
    "reachable": "reachable",
    "ported": "ported",
    "roaming": { "status": "not_roaming" },
    "real_time_data": {
     "active_status": "active",
     "handset_status": "on"
    }
}

返される各フィールドの説明と、可能なすべての値については Numbers Insight API ドキュメント