REST API: Lookup

Lookup サブドメインは、電話番号についての追加情報を取得するためのAPIを提供します。 Lookupは現在、地域固有の電話番号形式、キャリアー情報、そして発信者名情報(日本未対応)の取得に対応します。 リクエスト中では、購入を希望する情報タイプをひとつ以上指定できます。 Lookupはまた、Twilio Marketplace から利用できる複数のサードパーティーの事業者による情報を取得できるTwilio Add-on もサポートしています。

ルックアップ サブドメイン

リソースURI

lookups.twilio.com/v1/PhoneNumbers/{PhoneNumber}

{PhoneNumber} に情報の欲しい電話番号を入力します。情報の欲しい電話番号は標準的なE.164形式で入力する必要があります。電話番号が地域番号の場合、オプションパラメーターとして国を指定してください。国が指定されない場合、デフォルトは米国です。TwilioはGoogleオープンソース電話番号データベースであるlibphonenumberを使い、電話番号の地域、長さ、プレフィックスのフォーマットを特定します。

HTTP GET

リクエストの電話番号のマッチング結果を返します。電話番号の形式情報が標準です。アドオンを使用してサードパーティーのデータソースにアクセスするだけでなく、キャリア、発信者名および電話番号タイプをリクエストできます。

クエリーパラメーター

下記の標準的なGETクエリーは電話番号の情報のタイプを特定します。

パラメーター 説明
CountryCode オプション電話番号のISO国コード 番号が国際フォーマットで入力された時に利用されます。
Type Indicates the type of information you would like returned with your request. Possible values are carrier or caller-name. If not specified, the default is null.
Carrier information costs $0.005 per phone number looked up.
Caller Name information costs $0.01 per phone number looked up, and is currently ONLY available in the US.
You can retrieve both types of information by including two Type arguments or making two separate requests.
AddOns 詳細情報の取得のために使用する特定のアドオンを示します。可能な値は、アカウントにインストールされているアドオンの一意のアドオン名です。このパラメーターのインスタンスを複数指定することで、異なるアドオンを呼び出すことができます。
アドオンのインストールについては、アドオンのドキュメントを参照してください。アドオンの料金表は、コンソールのインストールされているアドオンのリストに示されています。
AddOns.add_on_unique_name.parameter_name オプション。リクエスト時に追加データをアドオンに渡します。アドオンで追加パラメーターが必要かどうかは、コンソールのアドオンのドキュメントで確認してください。このアドオンは、上記の AddOns パラメーターを使用してこのリクエストで呼び出す必要があります。

リソースのプロパティ

下記のプロパティは常に返されます。

プロパティ 説明
CountryCode この電話番号のISO 国コードです。
PhoneNumber 電話番号はE.154フォーマットです。(日本の場合"+81").
NationalFormat 国内番号フォーマットでの電話番号。
AddOns JSON ディクショナリーとして、リクエストで AddOn パラメーターを使用して指定したアドオンの結果。ディクショナリーのフォーマットについては、アドオンドキュメントのセクション 6 の「アドオンの使用」を参照してください。

情報を持ちうるできる番号(地域、長さ、プレフィックスの情報)はフォーマット化された結果を返します。存在しない番号のルックアップを試みた場合、HTTP404 エラーを返します。

キャリア情報

GETリクエスト中でキャリア情報をリクエストすると下記の追加情報が返却されます。

プロパティ 説明
MobileCountryCode キャリアのモバイル国コード(携帯電話番号のみ対象)
MobileNetworkCode キャリアのモバイルネットワークコード(携帯電話のみ対応)
名前 キャリア名キャリア名は頻繁に変わります。そのため Name も同様に変わります。
Type 電話番号タイプ取りうる値は、landlinemobileもしくはvoipです。詳しくは電話番号タイプをご覧ください。
ErrorCode このリクエストに関連するエラーコード
電話番号タイプ

下記は'Type'プロパティで取りうる値です。

Type 説明
landline この電話番号は固定電話で、一般的にSMSを受信することはできません。
携帯電話 この番号は携帯電話で、一般的にSMSを受信することができます。
voip インターネットをベースにした電話番号でSMSの受信は番号によります。例としてはGoogle Voiceがこれにあたります。

発信者の名前

GET リクエストで発信者名を要求した場合は、以下の追加のプロパティが返されます。

プロパティ 説明
CallerName 電話番号の所有者の名前を示す文字列。利用できない場合は、 null 返します。
CallerType この発信者がビジネスなのか消費者なのかを示す文字列。 取りうる値は business および consumer です。使用できない場合は、 unavailable を返します。
ErrorCode このリクエストに関連するエラーコード

米国の番号の発信者名ルックアップは、データがない場合でも、ルックアップごとに課金されます。現時点では、国際電話番号についての発信者名ルックアップをリクエストすると、値 null が返されますが、課金はされません。

サンプル

E.164フォーマットでキャリアの情報を検索します。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const LookupsClient = require('twilio').LookupsClient;
const client = new LookupsClient(accountSid, authToken);

client.phoneNumbers('+15108675310').get({
  type: 'carrier',
}, (error, number) => {
  console.log(number.carrier.type);
  console.log(number.carrier.name);
});
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+15108675310')
  .fetch()
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.Lookups;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    const string authToken = "your_auth_token";
    var lookupsClient = new LookupsClient(accountSid, authToken);

    // Look up a phone number in E.164 format
    var phoneNumber = lookupsClient.GetPhoneNumber("+15108675310", true);
    Console.WriteLine(phoneNumber.Carrier.Type);
    Console.WriteLine(phoneNumber.Carrier.Name);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Lookups_Services_Twilio($sid, $token);

$number = $client->phone_numbers->get("+15108675310", array("Type" => "carrier"));

echo $number->carrier->type . "\r\n";
echo $number->carrier->name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::LookupsClient.new account_sid, auth_token

number = @client.phone_numbers.get('+15108675310', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        // Look up a phone number in E.164 format
        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+15108675310"),
            type: new List<string> { "carrier" });

        Console.WriteLine(phoneNumber.Carrier["name"]);
        Console.WriteLine(phoneNumber.Carrier["type"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array("type" => "carrier")
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.lookups import TwilioLookupsClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioLookupsClient(account_sid, auth_token)

number = client.phone_numbers.get("+15108675310", include_carrier_info=True)
print(number.carrier['type'])
print(number.carrier['name'])
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

number = @client.lookups.v1.phone_numbers('+15108675310').fetch(type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.LookupsClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.lookups.PhoneNumber;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    LookupsClient client = new LookupsClient(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = client.getPhoneNumber("+15108675310", true);

    System.out.println(number.getType());
    System.out.println(number.getCarrierName());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(type="carrier")

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
        .setType("carrier")
        .fetch();

    System.out.println(number.getCarrier().get("name"));
    System.out.println(number.getCarrier().get("type"));
  }
}
curl -XGET https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
    "url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier",
    "carrier": {
        "error_code": null,
        "type": "mobile",
        "name": "T-Mobile USA, Inc.",
        "mobile_network_code": "160",
        "mobile_country_code": "310"
    },
    "national_format": "(510) 867-5310",
    "phone_number": "+15108675310",
    "country_code": "US"
}
E.164形式で電話番号を検索します
E.164 フォーマットの番号を使用したルックアップ

E.164形式で電話番号を検索します

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const LookupsClient = require('twilio').LookupsClient;
const client = new LookupsClient(accountSid, authToken);

client.phoneNumbers('(510) 867-5310').get({
  countryCode: 'US',
  type: 'carrier',
}, (error, number) => {
  console.log(number.carrier.type);
  console.log(number.carrier.name);
});
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('(510) 867-5310')
  .fetch({ countryCode: 'US', type: 'carrier' })
  .then(number => console.log(number.carrier.type, number.carrier.name));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.Lookups;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    const string authToken = "your_auth_token";
    var lookupsClient = new LookupsClient(accountSid, authToken);

    // Look up a phone number in local format
    var phoneNumber = lookupsClient.GetPhoneNumber("(510) 867-5310", "US", true);
    Console.WriteLine(phoneNumber.Carrier.Type);
    Console.WriteLine(phoneNumber.Carrier.Name); 
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Lookups_Services_Twilio($sid, $token);

$number = $client->phone_numbers->get("(510) 867-5310", array("CountryCode" => "US", "Type" => "carrier"));

echo $number->carrier->type . "\r\n";
echo $number->carrier->name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::LookupsClient.new account_sid, auth_token

number = client.phone_numbers
               .get('(510) 867-5310', country_code: 'US', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        // Look up a phone number in local format
        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("(510) 867-5310"),
            "US",
            new List<string> { "carrier" });

        Console.WriteLine(phoneNumber.Carrier["name"]);
        Console.WriteLine(phoneNumber.Carrier["type"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array("countryCode" => "US", "type" => "carrier")
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.lookups import TwilioLookupsClient

try:
    # Python 3
    from urllib.parse import quote
except ImportError:
    # Python 2
    from urllib import quote

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioLookupsClient(account_sid, auth_token)

encoded_number = quote('(510) 867-5310')
number = client.phone_numbers.get(
    encoded_number, include_carrier_info=True, country_code="US"
)
print(number.carrier['type'])
print(number.carrier['name'])
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'
require 'cgi'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('(510) 867-5310')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(country_code: 'US', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.LookupsClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.lookups.PhoneNumber;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException, UnsupportedEncodingException {
    LookupsClient client = new LookupsClient(ACCOUNT_SID, AUTH_TOKEN);

    String nationalNumber = URLEncoder.encode("(510) 867-5310", "UTF-8")
                            .replaceAll("\\+", "%20");
    PhoneNumber number = client.getPhoneNumber(nationalNumber, "US", true);

    System.out.println(number.getType());
    System.out.println(number.getCarrierName());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(
    type="carrier", country_code="US"
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws UnsupportedEncodingException {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    String nationalNumber = URLEncoder.encode("(510) 867-5310", "UTF-8").replaceAll("\\+", "%20");

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber(nationalNumber))
        .setType("carrier")
        .setCountryCode("US")
        .fetch();

    System.out.println(number.getCarrier().get("name"));
    System.out.println(number.getCarrier().get("type"));
  }
}
curl -XGET 'https://lookups.twilio.com/v1/PhoneNumbers/(510)%20867-5310?Type=carrier&CountryCode=US' \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
    "url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier",
    "carrier": {
        "error_code": null,
        "type": "mobile",
        "name": "T-Mobile USA, Inc.",
        "mobile_network_code": "160",
        "mobile_country_code": "310"
    },
    "national_format": "(510) 867-5310",
    "phone_number": "+15108675310",
    "country_code": "US"
}
国内フォーマットの番号を使用したルックアップ

ご注意: 下記の例では、Twilioの次世代ヘルパーライブラリーを使用しています。

コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+16502530000')
  .fetch({ type: 'caller-name' })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
	public static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		var phoneNumber = PhoneNumberResource.Fetch(
		    new PhoneNumber("+16502530000"),
		    type: new List<string> { "caller-name" });

		Console.WriteLine(phoneNumber.CallerName["caller_name"]);
	}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+16502530000")
    ->fetch(
        array("type" => "caller-name")
    );

echo $number->callerName['caller_type'] . "\r\n";
echo $number->callerName['caller_name'];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+16502530000')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(type: 'caller-name')

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+16502530000").fetch(
    type="caller-name",
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+16502530000"))
        .setType("caller-name")
        .fetch();

    System.out.println(number.getCallerName());
  }
}
$ curl -XGET https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?Type=caller-name \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}
発信者名を使用したルックアップ
コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+15108675310')
  .fetch({ type: ['carrier', 'caller-name'] })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+15108675310"),
            type: new List<string> { "caller-name", "carrier" });

        Console.WriteLine(phoneNumber.CallerName["caller_name"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array(
            "type" => array("carrier", "caller-name")
        )
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+15108675310')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(type: ['carrier', 'caller-name'])

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("15108675310").fetch(
    type=["carrier", "caller-name"],
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

import java.util.Arrays;

public class Example {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        PhoneNumber number = PhoneNumber
                .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
                .setType(Arrays.asList("caller-name", "carrier"))
                .fetch();

        System.out.println(number.getCallerName());
    }
}
curl -XGET "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310/?Type=carrier&Type=caller-name" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": {
    "mobile_country_code": null,
    "mobile_network_code": null,
    "name": "Level 3 Communications, LLC",
    "type": "landline",
    "error_code": null
  },
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000?Type=carrier"
}
キャリアーと発信者名を使用したルックアップ
コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+16502530000')
  .fetch({ addOns: 'whitepages_pro_caller_id' })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
	public static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		var phoneNumber = PhoneNumberResource.Fetch(
		    new PhoneNumber("+16502530000"),
		    addOns: new List<string> { "whitepages_pro_caller_id" });

		Console.WriteLine(phoneNumber.CallerName["caller_name"]);
	}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+16502530000")
    ->fetch(
        array("add_ons" => "whitepages_pro_caller_id")
    );

echo $number->callerName['caller_type'] . "\r\n";
echo $number->callerName['caller_name'];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+16502530000')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(add_ons: 'whitepages_pro_caller_id')

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+16502530000").fetch(
    add_ons="whitepages_pro_caller_id",
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+16502530000"))
        .setAddOns("whitepages_pro_caller_id")
        .fetch();

    System.out.println(number.getCallerName());
  }
}
curl -X GET https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=whitepages_pro_caller_id \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}
Lookup Add-onを使用して、電話番号についての追加情報を取得する
コードサンプルを読み込んでいます...
Language
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
const https = require('https');
const url = require('url').parse(
  'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101'
);
url.auth = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token';

https
  .get(url, res => {
    res.on('data', jsonString => {
      const lookup = JSON.parse(jsonString);
      const numberMatch =
        lookup.add_ons.results &&
        lookup.add_ons.results.payfone_tcpa_compliance.result.Response
          .NumberMatch;
      console.log(
        `Phone Number ${lookup.phone_number} is currently owned : ${numberMatch}`
      );
    });
  })
  .on('error', e => {
    console.log(`Got error: ${e.message}`);
  });
const https = require('https');
const url = require('url').parse(
  'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101'
);
url.auth = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token';

https
  .get(url, res => {
    res.on('data', jsonString => {
      const lookup = JSON.parse(jsonString);
      const numberMatch =
        lookup.add_ons.results &&
        lookup.add_ons.results.payfone_tcpa_compliance.result.Response
          .NumberMatch;
      console.log(
        `Phone Number ${lookup.phone_number} is currently owned : ${numberMatch}`
      );
    });
  })
  .on('error', e => {
    console.log(`Got error: ${e.message}`);
  });
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;

class Example
{
    static void Main(string[] args)
    {
        // The C# helper library will support Add-ons in June 2016, for now we'll use a simple RestSharp HTTP client
        var client = new RestClient("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101");
        // Find your Account Sid and Auth Token at twilio.com/user/account
        client.Authenticator = new HttpBasicAuthenticator("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "your_auth_token");
        var request = new RestRequest(Method.GET);
        request.AddHeader("content-type", "application/json");
        request.AddHeader("accept", "application/json");

        IRestResponse response = client.Execute(request);

        dynamic result = JsonConvert.DeserializeObject<Dictionary<string, string>>(
            response.Content, new JsonSerializerSettings { ContractResolver = new SnakeCaseContractResolver() });

        Console.WriteLine(result.add_ons.results.payfone_tcpa_compliance.result.Description);
        Console.WriteLine(result.add_ons.results.payfone_tcpa_compliance.result.Response.NumberMatch);
    }

    public class SnakeCaseContractResolver : DefaultContractResolver
    {
        protected override string ResolvePropertyName(string propertyName)
        {
            return GetSnakeCase(propertyName);
        }

        private string GetSnakeCase(string input)
        {
            if (string.IsNullOrEmpty(input))
                return input;

            var buffer = "";

            for (var i = 0; i < input.Length; i++)
            {
                var isLast = (i == input.Length - 1);
                var isSecondFromLast = (i == input.Length - 2);

                var curr = input[i];
                var next = !isLast ? input[i + 1] : '\0';
                var afterNext = !isSecondFromLast && !isLast ? input[i + 2] : '\0';

                buffer += char.ToLower(curr);

                if (!char.IsDigit(curr) && char.IsUpper(next))
                {
                    if (char.IsUpper(curr))
                    {
                        if (!isLast && !isSecondFromLast && !char.IsUpper(afterNext))
                            buffer += "_";
                    }
                    else
                        buffer += "_";
                }

                if (!char.IsDigit(curr) && char.IsDigit(next))
                    buffer += "_";
                if (char.IsDigit(curr) && !char.IsDigit(next) && !isLast)
                    buffer += "_";
            }

            return buffer;
        }
    }
}
<?php

$url = 'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101';

$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $additionalHeaders));
curl_setopt($process, CURLOPT_USERPWD, 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token');
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($process);
curl_close($process);
echo($response);

?>
require 'uri'
require 'net/http'

# Use Lookups API to get information about a phone number
url = URI("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
# All Twilio requests use HTTP basic auth -> http://en.wikipedia.org/wiki/Basic_access_authentication
request.basic_auth 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'
request["accept"] = 'application/json'
request["content-type"] = 'application/json'

response = http.request(request)
puts response.read_body
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var addOns = new List<string> { "payfone_tcpa_compliance" };
        var addOnsData = new Dictionary<string, object>
        {
            { "payfone_tcpa_compliance.RightPartyContactedDate", "20160101" }
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+16502530000"),
            addOns: addOns,
            addOnsData: addOnsData);

        Console.WriteLine(phoneNumber.Carrier);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array(
            "type" => "carrier",
            "addOns" => "payfone_tcpa_compliance",
            "addOnsData" => array(
                "payfone_tcpa_compliance" => array(
                    "RightPartyContactedDate" => "20160101"
                )
            )
        )
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
import requests

url = "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
}

response = requests.get(url, headers=headers, auth=('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'))

print(response.text)
require 'uri'
require 'net/http'

# Use Lookups API to get information about a phone number
url = URI('https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
# All Twilio requests use HTTP basic auth -> http://en.wikipedia.org/wiki/Basic_access_authentication
request.basic_auth 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'
request['accept'] = 'application/json'
request['content-type'] = 'application/json'

response = http.request(request)
puts response.read_body
package org.apache.http.examples.client;

import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class Example {

    public static void main(String[] args) throws Exception {
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(
                new AuthScope("lookups.twilio.com", 80),
                new UsernamePasswordCredentials("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "your_auth_token"));
        CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCredentialsProvider(credsProvider)
                .build();
        try {
            HttpGet httpget = new HttpGet("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101");

            System.out.println("Executing request " + httpget.getRequestLine());
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                System.out.println(response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(
    type="carrier",
    add_ons="payfone_tcpa_compliance",
    add_ons_data={
        "payfone_tcpa_compliance": {
            "RightPartyContactedDate": "20160101"
        }
    }
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);


    Map<String, Object> complianceData = new HashMap<>();
    complianceData.put("RightPartyContactedDate", "20160101");

    Map<String, Object> addOnData = new HashMap<>();
    addOnData.put("payfone_tcpa_compliance", complianceData);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
        .setType("carrier")
        .setAddOns("payfone_tcpa_compliance")
        .setAddOnsData(addOnData)
        .fetch();

    System.out.println(number.getCarrier());
  }
}
$ curl -XGET 'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101' \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
testable: true
test_output: false
exclude_languages:
  - python
  - java6
{
  "caller_name": null,
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "add_ons": {
    "status": "successful",
    "message": null,
    "code": null,
    "results": {
      "payfone_tcpa_compliance": {
        "status": "successful",
        "message": null,
        "code": null,
        "result": {
          "RequestId": "XR915eb8ea1d50cc671dc60c4fed78cfe5",
          "Status": 0,
          "Description": "Success.",
          "Response": {
            "VerifyNumberTransactionId": "1139195097",
            "PayfoneAlias": null,
            "MSISDNType": "Landline",
            "NumberMatch": "I"
          }
        },
        "requestSid": "XR915eb8ea1d50cc671dc60c4fed78cfe5"
      }
    }
  },
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}
Payfone TCPA Compliance Add-onの結果を含む電話番号をルックアップします。
アドオンを有効にしたルックアップ

Payfone TCPA Compliance Add-onの結果を含む電話番号をルックアップします。

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

コードサンプルを読み込んでいます...
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const LookupsClient = require('twilio').LookupsClient;
const client = new LookupsClient(accountSid, authToken);

client.phoneNumbers('+15108675310').get({
  type: 'carrier',
}, (error, number) => {
  console.log(number.carrier.type);
  console.log(number.carrier.name);
});
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+15108675310')
  .fetch()
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.Lookups;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    const string authToken = "your_auth_token";
    var lookupsClient = new LookupsClient(accountSid, authToken);

    // Look up a phone number in E.164 format
    var phoneNumber = lookupsClient.GetPhoneNumber("+15108675310", true);
    Console.WriteLine(phoneNumber.Carrier.Type);
    Console.WriteLine(phoneNumber.Carrier.Name);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Lookups_Services_Twilio($sid, $token);

$number = $client->phone_numbers->get("+15108675310", array("Type" => "carrier"));

echo $number->carrier->type . "\r\n";
echo $number->carrier->name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::LookupsClient.new account_sid, auth_token

number = @client.phone_numbers.get('+15108675310', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        // Look up a phone number in E.164 format
        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+15108675310"),
            type: new List<string> { "carrier" });

        Console.WriteLine(phoneNumber.Carrier["name"]);
        Console.WriteLine(phoneNumber.Carrier["type"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array("type" => "carrier")
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.lookups import TwilioLookupsClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioLookupsClient(account_sid, auth_token)

number = client.phone_numbers.get("+15108675310", include_carrier_info=True)
print(number.carrier['type'])
print(number.carrier['name'])
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

number = @client.lookups.v1.phone_numbers('+15108675310').fetch(type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.LookupsClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.lookups.PhoneNumber;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException {
    LookupsClient client = new LookupsClient(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = client.getPhoneNumber("+15108675310", true);

    System.out.println(number.getType());
    System.out.println(number.getCarrierName());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(type="carrier")

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
        .setType("carrier")
        .fetch();

    System.out.println(number.getCarrier().get("name"));
    System.out.println(number.getCarrier().get("type"));
  }
}
curl -XGET https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
    "url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier",
    "carrier": {
        "error_code": null,
        "type": "mobile",
        "name": "T-Mobile USA, Inc.",
        "mobile_network_code": "160",
        "mobile_country_code": "310"
    },
    "national_format": "(510) 867-5310",
    "phone_number": "+15108675310",
    "country_code": "US"
}
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from twilio.com/user/account
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const LookupsClient = require('twilio').LookupsClient;
const client = new LookupsClient(accountSid, authToken);

client.phoneNumbers('(510) 867-5310').get({
  countryCode: 'US',
  type: 'carrier',
}, (error, number) => {
  console.log(number.carrier.type);
  console.log(number.carrier.name);
});
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('(510) 867-5310')
  .fetch({ countryCode: 'US', type: 'carrier' })
  .then(number => console.log(number.carrier.type, number.carrier.name));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.Lookups;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    const string authToken = "your_auth_token";
    var lookupsClient = new LookupsClient(accountSid, authToken);

    // Look up a phone number in local format
    var phoneNumber = lookupsClient.GetPhoneNumber("(510) 867-5310", "US", true);
    Console.WriteLine(phoneNumber.Carrier.Type);
    Console.WriteLine(phoneNumber.Carrier.Name); 
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Lookups_Services_Twilio($sid, $token);

$number = $client->phone_numbers->get("(510) 867-5310", array("CountryCode" => "US", "Type" => "carrier"));

echo $number->carrier->type . "\r\n";
echo $number->carrier->name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Twilio::REST::LookupsClient.new account_sid, auth_token

number = client.phone_numbers
               .get('(510) 867-5310', country_code: 'US', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        // Look up a phone number in local format
        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("(510) 867-5310"),
            "US",
            new List<string> { "carrier" });

        Console.WriteLine(phoneNumber.Carrier["name"]);
        Console.WriteLine(phoneNumber.Carrier["type"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array("countryCode" => "US", "type" => "carrier")
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest.lookups import TwilioLookupsClient

try:
    # Python 3
    from urllib.parse import quote
except ImportError:
    # Python 2
    from urllib import quote

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = TwilioLookupsClient(account_sid, auth_token)

encoded_number = quote('(510) 867-5310')
number = client.phone_numbers.get(
    encoded_number, include_carrier_info=True, country_code="US"
)
print(number.carrier['type'])
print(number.carrier['name'])
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'
require 'cgi'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('(510) 867-5310')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(country_code: 'US', type: 'carrier')

puts number.carrier['type']
puts number.carrier['name']
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.LookupsClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.lookups.PhoneNumber;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Example {

  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws TwilioRestException, UnsupportedEncodingException {
    LookupsClient client = new LookupsClient(ACCOUNT_SID, AUTH_TOKEN);

    String nationalNumber = URLEncoder.encode("(510) 867-5310", "UTF-8")
                            .replaceAll("\\+", "%20");
    PhoneNumber number = client.getPhoneNumber(nationalNumber, "US", true);

    System.out.println(number.getType());
    System.out.println(number.getCarrierName());
  }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(
    type="carrier", country_code="US"
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) throws UnsupportedEncodingException {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    String nationalNumber = URLEncoder.encode("(510) 867-5310", "UTF-8").replaceAll("\\+", "%20");

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber(nationalNumber))
        .setType("carrier")
        .setCountryCode("US")
        .fetch();

    System.out.println(number.getCarrier().get("name"));
    System.out.println(number.getCarrier().get("type"));
  }
}
curl -XGET 'https://lookups.twilio.com/v1/PhoneNumbers/(510)%20867-5310?Type=carrier&CountryCode=US' \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
    "url": "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310?Type=carrier",
    "carrier": {
        "error_code": null,
        "type": "mobile",
        "name": "T-Mobile USA, Inc.",
        "mobile_network_code": "160",
        "mobile_country_code": "310"
    },
    "national_format": "(510) 867-5310",
    "phone_number": "+15108675310",
    "country_code": "US"
}
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+16502530000')
  .fetch({ type: 'caller-name' })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
	public static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		var phoneNumber = PhoneNumberResource.Fetch(
		    new PhoneNumber("+16502530000"),
		    type: new List<string> { "caller-name" });

		Console.WriteLine(phoneNumber.CallerName["caller_name"]);
	}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+16502530000")
    ->fetch(
        array("type" => "caller-name")
    );

echo $number->callerName['caller_type'] . "\r\n";
echo $number->callerName['caller_name'];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+16502530000')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(type: 'caller-name')

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+16502530000").fetch(
    type="caller-name",
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+16502530000"))
        .setType("caller-name")
        .fetch();

    System.out.println(number.getCallerName());
  }
}
$ curl -XGET https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?Type=caller-name \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+15108675310')
  .fetch({ type: ['carrier', 'caller-name'] })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+15108675310"),
            type: new List<string> { "caller-name", "carrier" });

        Console.WriteLine(phoneNumber.CallerName["caller_name"]);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array(
            "type" => array("carrier", "caller-name")
        )
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+15108675310')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(type: ['carrier', 'caller-name'])

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("15108675310").fetch(
    type=["carrier", "caller-name"],
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

import java.util.Arrays;

public class Example {
    // Find your Account Sid and Token at twilio.com/user/account
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        PhoneNumber number = PhoneNumber
                .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
                .setType(Arrays.asList("caller-name", "carrier"))
                .fetch();

        System.out.println(number.getCallerName());
    }
}
curl -XGET "https://lookups.twilio.com/v1/PhoneNumbers/+15108675310/?Type=carrier&Type=caller-name" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": {
    "mobile_country_code": null,
    "mobile_network_code": null,
    "name": "Level 3 Communications, LLC",
    "type": "landline",
    "error_code": null
  },
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000?Type=carrier"
}
SDKバージョン:
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 7.x
SDKバージョン:
  • 3.x
SDKバージョン:
  • 5.x
SDKバージョン:
  • 6.x
SDKバージョン:
  • 5.x
形式:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';

const client = require('twilio')(accountSid, authToken);

client.lookups.v1
  .phoneNumbers('+16502530000')
  .fetch({ addOns: 'whitepages_pro_caller_id' })
  .then(number => console.log(number));
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

public class Example
{
	public static void Main(string[] args)
	{
		// Find your Account SID and Auth Token at twilio.com/console
		const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
		const string authToken = "your_auth_token";

		TwilioClient.Init(accountSid, authToken);

		var phoneNumber = PhoneNumberResource.Fetch(
		    new PhoneNumber("+16502530000"),
		    addOns: new List<string> { "whitepages_pro_caller_id" });

		Console.WriteLine(phoneNumber.CallerName["caller_name"]);
	}
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+16502530000")
    ->fetch(
        array("add_ons" => "whitepages_pro_caller_id")
    );

echo $number->callerName['caller_type'] . "\r\n";
echo $number->callerName['caller_name'];
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'twilio-ruby'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

encoded_phone_number = CGI.escape('+16502530000')
number = @client.lookups.v1
                .phone_numbers(encoded_phone_number)
                .fetch(add_ons: 'whitepages_pro_caller_id')

puts number.carrier['type']
puts number.carrier['name']
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+16502530000").fetch(
    add_ons="whitepages_pro_caller_id",
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+16502530000"))
        .setAddOns("whitepages_pro_caller_id")
        .fetch();

    System.out.println(number.getCallerName());
  }
}
curl -X GET https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=whitepages_pro_caller_id \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
{
  "caller_name": {
    "caller_name": "YOU TUBE",
    "caller_type": "BUSINESS",
    "error_code": null
  },
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}
SDKバージョン:
  • 4.x
  • 5.x
レスポンス形式:
  • JSON
SDKバージョン:
  • 6.x
  • 7.x
SDKバージョン:
  • 2.x
  • 3.x
SDKバージョン:
  • 4.x
  • 5.x
SDKバージョン:
  • 5.x
  • 6.x
SDKバージョン:
  • 4.x
  • 5.x
形式:
  • JSON
const https = require('https');
const url = require('url').parse(
  'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101'
);
url.auth = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token';

https
  .get(url, res => {
    res.on('data', jsonString => {
      const lookup = JSON.parse(jsonString);
      const numberMatch =
        lookup.add_ons.results &&
        lookup.add_ons.results.payfone_tcpa_compliance.result.Response
          .NumberMatch;
      console.log(
        `Phone Number ${lookup.phone_number} is currently owned : ${numberMatch}`
      );
    });
  })
  .on('error', e => {
    console.log(`Got error: ${e.message}`);
  });
const https = require('https');
const url = require('url').parse(
  'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101'
);
url.auth = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token';

https
  .get(url, res => {
    res.on('data', jsonString => {
      const lookup = JSON.parse(jsonString);
      const numberMatch =
        lookup.add_ons.results &&
        lookup.add_ons.results.payfone_tcpa_compliance.result.Response
          .NumberMatch;
      console.log(
        `Phone Number ${lookup.phone_number} is currently owned : ${numberMatch}`
      );
    });
  })
  .on('error', e => {
    console.log(`Got error: ${e.message}`);
  });
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;

class Example
{
    static void Main(string[] args)
    {
        // The C# helper library will support Add-ons in June 2016, for now we'll use a simple RestSharp HTTP client
        var client = new RestClient("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101");
        // Find your Account Sid and Auth Token at twilio.com/user/account
        client.Authenticator = new HttpBasicAuthenticator("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "your_auth_token");
        var request = new RestRequest(Method.GET);
        request.AddHeader("content-type", "application/json");
        request.AddHeader("accept", "application/json");

        IRestResponse response = client.Execute(request);

        dynamic result = JsonConvert.DeserializeObject<Dictionary<string, string>>(
            response.Content, new JsonSerializerSettings { ContractResolver = new SnakeCaseContractResolver() });

        Console.WriteLine(result.add_ons.results.payfone_tcpa_compliance.result.Description);
        Console.WriteLine(result.add_ons.results.payfone_tcpa_compliance.result.Response.NumberMatch);
    }

    public class SnakeCaseContractResolver : DefaultContractResolver
    {
        protected override string ResolvePropertyName(string propertyName)
        {
            return GetSnakeCase(propertyName);
        }

        private string GetSnakeCase(string input)
        {
            if (string.IsNullOrEmpty(input))
                return input;

            var buffer = "";

            for (var i = 0; i < input.Length; i++)
            {
                var isLast = (i == input.Length - 1);
                var isSecondFromLast = (i == input.Length - 2);

                var curr = input[i];
                var next = !isLast ? input[i + 1] : '\0';
                var afterNext = !isSecondFromLast && !isLast ? input[i + 2] : '\0';

                buffer += char.ToLower(curr);

                if (!char.IsDigit(curr) && char.IsUpper(next))
                {
                    if (char.IsUpper(curr))
                    {
                        if (!isLast && !isSecondFromLast && !char.IsUpper(afterNext))
                            buffer += "_";
                    }
                    else
                        buffer += "_";
                }

                if (!char.IsDigit(curr) && char.IsDigit(next))
                    buffer += "_";
                if (char.IsDigit(curr) && !char.IsDigit(next) && !isLast)
                    buffer += "_";
            }

            return buffer;
        }
    }
}
<?php

$url = 'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101';

$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $additionalHeaders));
curl_setopt($process, CURLOPT_USERPWD, 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token');
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($process);
curl_close($process);
echo($response);

?>
require 'uri'
require 'net/http'

# Use Lookups API to get information about a phone number
url = URI("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
# All Twilio requests use HTTP basic auth -> http://en.wikipedia.org/wiki/Basic_access_authentication
request.basic_auth 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'
request["accept"] = 'application/json'
request["content-type"] = 'application/json'

response = http.request(request)
puts response.read_body
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Lookups.V1;
using Twilio.Types;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var addOns = new List<string> { "payfone_tcpa_compliance" };
        var addOnsData = new Dictionary<string, object>
        {
            { "payfone_tcpa_compliance.RightPartyContactedDate", "20160101" }
        };

        var phoneNumber = PhoneNumberResource.Fetch(
            new PhoneNumber("+16502530000"),
            addOns: addOns,
            addOnsData: addOnsData);

        Console.WriteLine(phoneNumber.Carrier);
    }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";

$client = new Client($sid, $token);

$number = $client->lookups
    ->phoneNumbers("+15108675310")
    ->fetch(
        array(
            "type" => "carrier",
            "addOns" => "payfone_tcpa_compliance",
            "addOnsData" => array(
                "payfone_tcpa_compliance" => array(
                    "RightPartyContactedDate" => "20160101"
                )
            )
        )
    );

echo $number->carrier["type"] . "\r\n";
echo $number->carrier["name"];
import requests

url = "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
}

response = requests.get(url, headers=headers, auth=('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'))

print(response.text)
require 'uri'
require 'net/http'

# Use Lookups API to get information about a phone number
url = URI('https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
# All Twilio requests use HTTP basic auth -> http://en.wikipedia.org/wiki/Basic_access_authentication
request.basic_auth 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token'
request['accept'] = 'application/json'
request['content-type'] = 'application/json'

response = http.request(request)
puts response.read_body
package org.apache.http.examples.client;

import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class Example {

    public static void main(String[] args) throws Exception {
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(
                new AuthScope("lookups.twilio.com", 80),
                new UsernamePasswordCredentials("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "your_auth_token"));
        CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCredentialsProvider(credsProvider)
                .build();
        try {
            HttpGet httpget = new HttpGet("https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101");

            System.out.println("Executing request " + httpget.getRequestLine());
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                System.out.println(response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
            } finally {
                response.close();
            }
        } finally {
            httpclient.close();
        }
    }
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACCOUNT_SID"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

number = client.lookups.phone_numbers("+15108675310").fetch(
    type="carrier",
    add_ons="payfone_tcpa_compliance",
    add_ons_data={
        "payfone_tcpa_compliance": {
            "RightPartyContactedDate": "20160101"
        }
    }
)

print(number.carrier['type'])
print(number.carrier['name'])
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);


    Map<String, Object> complianceData = new HashMap<>();
    complianceData.put("RightPartyContactedDate", "20160101");

    Map<String, Object> addOnData = new HashMap<>();
    addOnData.put("payfone_tcpa_compliance", complianceData);

    PhoneNumber number = PhoneNumber
        .fetcher(new com.twilio.type.PhoneNumber("+15108675310"))
        .setType("carrier")
        .setAddOns("payfone_tcpa_compliance")
        .setAddOnsData(addOnData)
        .fetch();

    System.out.println(number.getCarrier());
  }
}
$ curl -XGET 'https://lookups.twilio.com/v1/PhoneNumbers/+16502530000/?AddOns=payfone_tcpa_compliance&AddOns.payfone_tcpa_compliance.RightPartyContactedDate=20160101' \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
testable: true
test_output: false
exclude_languages:
  - python
  - java6
{
  "caller_name": null,
  "country_code": "US",
  "phone_number": "+16502530000",
  "national_format": "(650) 253-0000",
  "carrier": null,
  "add_ons": {
    "status": "successful",
    "message": null,
    "code": null,
    "results": {
      "payfone_tcpa_compliance": {
        "status": "successful",
        "message": null,
        "code": null,
        "result": {
          "RequestId": "XR915eb8ea1d50cc671dc60c4fed78cfe5",
          "Status": 0,
          "Description": "Success.",
          "Response": {
            "VerifyNumberTransactionId": "1139195097",
            "PayfoneAlias": null,
            "MSISDNType": "Landline",
            "NumberMatch": "I"
          }
        },
        "requestSid": "XR915eb8ea1d50cc671dc60c4fed78cfe5"
      }
    }
  },
  "url": "https://lookups.twilio.com/v1/PhoneNumbers/+16502530000"
}