Skip to main content

Quickstart for Number Lookup

Lookup: Carrier and caller name

| cURL | Python | Node | Ruby |


cURL

Number Lookup is a service offered by the Telnyx SDK that allows the user to look up a phone number and retrieve information regarding that phone number such as:

  • Carrier name
  • Type of phone (landline, mobile, etc.)
  • Name and business associated with the number

Basic number lookup example

Running the following code will perform a number lookup on the given number parameter.

curl -X GET \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer YOUR_API_KEY" \
--globoff "https://api.telnyx.com/v2/number_lookup/+18665552368"

Note: After pasting the above content, Kindly check and remove any new line added

The response will look something like this:

{
"data": {
"caller_name": {
"caller_name": "TELNYX LLC",
"error_code": "10001"
},
"carrier": {
"error_code": null,
"mobile_country_code": "US",
"mobile_network_code": 866,
"name": "Telnyx/4",
"type": "voip"
},
"country_code": "US",
"fraud": null,
"national_format": "(0312) 945-7420",
"phone_number": "+13129457420",
"portability": {
"altspid": "073H",
"altspid_carrier_name": "Telnyx/4",
"altspid_carrier_type": "3",
"city": "WAUKEGAN",
"line_type": "voip",
"lrn": "2245701999",
"ocn": "073H",
"ported_date": "2017-10-20",
"ported_status": "Y",
"spid": "073H",
"spid_carrier_name": "Telnyx/4",
"spid_carrier_type": "3",
"state": "Illinois"
},
"record_type": "number_lookup"
}
}

Note: After pasting the above content, Kindly check and remove any new line added

This example shows results for a Telnyx user-owned number. It displays the formatted version of the number in the national-format value. The location of the number can be seen under portability -> city and state. Other useful information such as carrier and caller_name can be retrieved if available.

Retrieving caller name and carrier

Users may also specify the type of the request in order to receive information about the carrier and caller-name. Note that the request will always return the same object, however if the caller-name and carrier options are not sent, the return values will be null. An example of adding both these parameters to the request is shown below:

curl -X GET \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Bearer YOUR_API_KEY" \
--globoff "https://api.telnyx.com/v2/number_lookup/+18665552368?carrier&caller-name"

Note: After pasting the above content, Kindly check and remove any new line added

Python

Number Lookup is a serviceis a service offered by the Telnyx SDK that allows the user to look up a phone number and retrieve information regarding that phone number such as:

  • Carrier name
  • Type of phone (landline, mobile, etc.)
  • Name and business associated with the number

Basic number lookup example

Running the following code will perform a number lookup on the given number parameter using Python.

import telnyx
telnyx.api_key = "YOUR_API_KEY"
telnyx.NumberLookup.retrieve(+13129457420)

Note: After pasting the above content, Kindly check and remove any new line added

The response will look something like this:

{
"data": {
"caller_name": {
"caller_name": "TELNYX LLC",
"error_code": "10001"
},
"carrier": {
"error_code": null,
"mobile_country_code": "US",
"mobile_network_code": 866,
"name": "Telnyx/4",
"type": "voip"
},
"country_code": "US",
"fraud": null,
"national_format": "(0312) 945-7420",
"phone_number": "+13129457420",
"portability": {
"altspid": "073H",
"altspid_carrier_name": "Telnyx/4",
"altspid_carrier_type": "3",
"city": "WAUKEGAN",
"line_type": "voip",
"lrn": "2245701999",
"ocn": "073H",
"ported_date": "2017-10-20",
"ported_status": "Y",
"spid": "073H",
"spid_carrier_name": "Telnyx/4",
"spid_carrier_type": "3",
"state": "Illinois"
},
"record_type": "number_lookup"
}
}

Note: After pasting the above content, Kindly check and remove any new line added

This example shows results for a Telnyx user-owned number. It displays the formatted version of the number in the national-format value. The location of the number can be seen under portability -> city and state.

Retrieving caller name and carrier

Users may also specify the type of the request in order to receive information about the carrier and caller-name. Note that the request will always return the same object, however if the caller-name and carrier options are not sent, the return values will be null.

Node

Number Lookup is a serviceoffered by the Telnyx SDK that allows the user to look up a phone number and retrieve information regarding that phone number such as:

  • Carrier name
  • Type of phone (landline, mobile, etc.)
  • Name and business associated with the number

Basic number lookup example

Running the following code will perform a number lookup on the given number parameter.

var telnyx = require('telnyx')('YOUR_API_KEY');

// In Node 10
const { data: numberInfo } = await telnyx.numberLookup.retrieve(
'+18665552368'
);

// In other environments
telnyx.numberLookup.retrieve(
'+18665552368'
).then(function(response){
const numberInfo = response.data; // asynchronously handled
});

Note: After pasting the above content, Kindly check and remove any new line added

The response will look something like this:

{
"data": {
"caller_name": {
"caller_name": "TELNYX LLC",
"error_code": "10001"
},
"carrier": {
"error_code": null,
"mobile_country_code": "US",
"mobile_network_code": 866,
"name": "Telnyx/4",
"type": "voip"
},
"country_code": "US",
"fraud": null,
"national_format": "(0312) 945-7420",
"phone_number": "+13129457420",
"portability": {
"altspid": "073H",
"altspid_carrier_name": "Telnyx/4",
"altspid_carrier_type": "3",
"city": "WAUKEGAN",
"line_type": "voip",
"lrn": "2245701999",
"ocn": "073H",
"ported_date": "2017-10-20",
"ported_status": "Y",
"spid": "073H",
"spid_carrier_name": "Telnyx/4",
"spid_carrier_type": "3",
"state": "Illinois"
},
"record_type": "number_lookup"
}
}

Note: After pasting the above content, Kindly check and remove any new line added

This example shows results for a Telnyx user-owned number. It displays the formatted version of the number in the national-format value. The location of the number can be seen under portability -> city and state. Other useful information such as carrier and caller_name can be retrieved if available.

Retrieving caller name and carrier

Users may also specify the type of the request in order to receive information about the carrier and caller-name. Note that the request will always return the same object, however if the caller-name and carrier options are not sent, the return values will be null. An example request for these options is shown below:

var telnyx = require('telnyx')('YOUR_API_KEY');

// In Node 10
const { data: numberInfo } = await telnyx.numberLookup.retrieve(
'+18665552368',
{
type: ["caller-name", "carrier"]
}
);

// In other environments
telnyx.numberLookup.retrieve(
'+18665552368',
{
type: ["caller-name", "carrier"]
}
).then(function(response){
const numberInfo = response.data; // asynchronously handled
});

Note: After pasting the above content, Kindly check and remove any new line added

Ruby

Number Lookup is a service is a service offered by the Telnyx SDK that allows the user to look up a phone number and retrieve information regarding that phone number such as:

  • Carrier name
  • Type of phone (landline, mobile, etc.)
  • Name and business associated with the number

Basic number lookup example

Running the following code will perform a number lookup on the given number parameter.

require "telnyx"
Telnyx.api_key = "YOUR_API_KEY"

Telnyx::NumberLookup.retrieve('+12624755500')

Note: After pasting the above content, Kindly check and remove any new line added

The response will look something like this:

{
"data": {
"caller_name": {
"caller_name": "TELNYX LLC",
"error_code": "10001"
},
"carrier": {
"error_code": null,
"mobile_country_code": "US",
"mobile_network_code": 866,
"name": "Telnyx/4",
"type": "voip"
},
"country_code": "US",
"fraud": null,
"national_format": "(0312) 945-7420",
"phone_number": "+13129457420",
"portability": {
"altspid": "073H",
"altspid_carrier_name": "Telnyx/4",
"altspid_carrier_type": "3",
"city": "WAUKEGAN",
"line_type": "voip",
"lrn": "2245701999",
"ocn": "073H",
"ported_date": "2017-10-20",
"ported_status": "Y",
"spid": "073H",
"spid_carrier_name": "Telnyx/4",
"spid_carrier_type": "3",
"state": "Illinois"
},
"record_type": "number_lookup"
}
}

Note: After pasting the above content, Kindly check and remove any new line added

This example shows results for a Telnyx user-owned number. It displays the formatted version of the number in the national-format value. The location of the number can be seen under portability -> city and state. Other useful information such as carrier and caller_name can be retrieved if available.

Retrieving caller name and carrier

Users may also specify the type of the request in order to receive information about the carrier and caller-name. Note that the request will always return the same object, however if the caller-name and carrier options are not sent, the return values will be null.

On this page