vonage.numberinsight
Module vonage.numberinsight
API
Definitions
ballerinax/vonage.numberinsight Ballerina library
Overview
The Vonage Number Insight API v1.0.10 connector(https://nexmo-api-specification.herokuapp.com/number-insight) OpenAPI specification. The Number Insight API delivers real-time intelligence about the validity, reachability and roaming status of a phone number and tells you how to format the number correctly in your application. There are three levels of Number Insight API available: Basic, Standard and Advanced. The advanced API is available asynchronously as well as synchronously. More Number Insight API documentation is at https://developer.nexmo.com/number-insight/overview#number-insight-api-overview.
Key Features
- Programmatic access to create and manage resources via REST API
- Access analytics, reports, and performance metrics
- Manage user accounts and profiles
- Secure authentication with API key or OAuth support
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create Vonage account
- Obtain tokens
- Log into Vonage API Dashboard by visiting https://dashboard.nexmo.com/
- Obtain the
API KeyandAPI Secretfrom the API Dashboard.
Quickstart
To use the Vonage Number Insight connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
First, import the ballerinax/vonage.numberinsight module into the Ballerina project.
import ballerinax/vonage.numberinsight as vn;
Step 2: Create a new connector instance
Create a numberinsight:ApiKeysConfig with the API key and API secret obtained, and initialize the connector with it.
vn:ApiKeysConfig config = { apiKey: "<API_KEY>", apiSecret: "<API_SECRET" } vn:Client baseClient = check new Client();
Step 3: Invoke connector operation
-
Now you can use the operations available within the connector. Note that they are in the form of remote operations.
Following is an example on how to get basic number insight information about a number using the connector.
Basic Number Insight
public function main() { vn:NiResponseJsonBasic|error response = baseClient->getNumberInsightBasic("json", "9477.....83"); if (response is vn:NiResponseJsonBasic) { log:printInfo(response.toString()); } else { log:printError(response.message()); } }Following is an example on how to get standard number insight information about a number using the connector.
Standard Number Insight
public function main() { vn:NiResponseJsonStandard|error response = baseClient->getNumberInsightStandard("json", "9477.....83"); if (response is vn:NiResponseJsonStandard) { log:printInfo(response.toString()); } else { log:printError(response.message()); } }Following is an example on how to get advanced number insight information about a number using the connector.
Advanced Number Insight (async)
public function main() { vn:NiResponseJsonAdvanced|error response = baseClient->getNumberInsightAdvanced("json", "9477.....83"); if (response is vn:NiResponseJsonAdvanced) { log:printInfo(response.toString()); } else { log:printError(response.message()); } } -
Use
bal runcommand to compile and run the Ballerina program.
Clients
vonage.numberinsight: Client
This is a generated connector for Vonage Number Insight API v1.0.10 OpenAPI specification. The Number Insight API delivers real-time intelligence about the validity, reachability and roaming status of a phone number and tells you how to format the number correctly in your application. There are three levels of Number Insight API available: Basic, Standard and Advanced. The advanced API is available asynchronously as well as synchronously. More Number Insight API documentation is at https://developer.nexmo.com/number-insight/overview#number-insight-api-overview.
Constructor
Gets invoked to initialize the connector.
The connector initialization requires setting the API credentials.
Create a Vonage account and obtain tokens by following this guide.
init (ApiKeysConfig apiKeyConfig, ConnectionConfig config, string serviceUrl)- apiKeyConfig ApiKeysConfig - API keys for authorization
- config ConnectionConfig {} - The configurations to be used when initializing the
connector
- serviceUrl string "https://api.nexmo.com/ni" - URL of the target service
getNumberInsightBasic
function getNumberInsightBasic(string format, string number, string? country) returns NiResponseJsonBasic|errorBasic Number Insight
Parameters
- format string - The format of the response
- number string - A single phone number that you need insight about in national or international format.
- country string? (default ()) - If a number does not have a country code or is uncertain, set the two-character country code. This code must be in ISO 3166-1 alpha-2 format and in upper case. For example, GB or US. If you set country and number is already in E.164 format, country must match the country code in number.
Return Type
- NiResponseJsonBasic|error - OK
getNumberInsightStandard
function getNumberInsightStandard(string format, string number, string? country, boolean cnam) returns NiResponseJsonStandard|errorStandard Number Insight
Parameters
- format string - The format of the response
- number string - A single phone number that you need insight about in national or international format.
- country string? (default ()) - If a number does not have a country code or is uncertain, set the two-character country code. This code must be in ISO 3166-1 alpha-2 format and in upper case. For example, GB or US. If you set country and number is already in E.164 format, country must match the country code in number.
- cnam boolean (default false) - Indicates if the name of the person who owns the phone number should be looked up and returned in the response. Set to true to receive phone number owner name in the response. This features is available for US numbers only and incurs an additional charge.
Return Type
getNumberInsightAsync
function getNumberInsightAsync(string format, string callback, string number, string? country, boolean cnam, string? ip) returns NiResponseAsync|errorAdvanced Number Insight (async)
Parameters
- format string - The format of the response
- callback string - The callback URL
- number string - A single phone number that you need insight about in national or international format.
- country string? (default ()) - If a number does not have a country code or is uncertain, set the two-character country code. This code must be in ISO 3166-1 alpha-2 format and in upper case. For example, GB or US. If you set country and number is already in E.164 format, country must match the country code in number.
- cnam boolean (default false) - Indicates if the name of the person who owns the phone number should be looked up and returned in the response. Set to true to receive phone number owner name in the response. This features is available for US numbers only and incurs an additional charge.
- ip string? (default ()) - This parameter is deprecated as we are no longer able to retrieve reliable IP data globally from carriers.
Deprecated parameters
This parameter is deprecated as we are no longer able to retrieve reliable IP data globally from carriers.
Return Type
- NiResponseAsync|error - OK
Deprecated parameters
getNumberInsightAdvanced
function getNumberInsightAdvanced(string format, string number, string? country, boolean cnam, string? ip) returns NiResponseJsonAdvanced|errorAdvanced Number Insight (sync)
Parameters
- format string - The format of the response
- number string - A single phone number that you need insight about in national or international format.
- country string? (default ()) - If a number does not have a country code or is uncertain, set the two-character country code. This code must be in ISO 3166-1 alpha-2 format and in upper case. For example, GB or US. If you set country and number is already in E.164 format, country must match the country code in number.
- cnam boolean (default false) - Indicates if the name of the person who owns the phone number should be looked up and returned in the response. Set to true to receive phone number owner name in the response. This features is available for US numbers only and incurs an additional charge.
- ip string? (default ()) - This parameter is deprecated as we are no longer able to retrieve reliable IP data globally from carriers.
Deprecated parameters
This parameter is deprecated as we are no longer able to retrieve reliable IP data globally from carriers.
Return Type
Deprecated parameters
Records
vonage.numberinsight: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- apiKey string - You can find your API key in your account overview
- apiSecret string - You can find your API secret in your account overview
vonage.numberinsight: ClientHttp1Settings
Provides settings related to HTTP/1.x protocol.
Fields
- keepAlive KeepAlive(default http:KEEPALIVE_AUTO) - Specifies whether to reuse a connection for multiple requests
- chunking Chunking(default http:CHUNKING_AUTO) - The chunking behaviour of the request
- proxy? ProxyConfig - Proxy server related options
vonage.numberinsight: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings? ClientHttp1Settings - Configurations related to HTTP/1.x protocol
- http2Settings? ClientHttp2Settings - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded/x-forwardedheader
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache? CacheConfig - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- responseLimits? ResponseLimitConfigs - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
vonage.numberinsight: NiCallerIdentity
Information about the network number is currently connected to.
Fields
- caller_type? string? - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- caller_name? string? - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- first_name? string? - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- last_name? string? - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
vonage.numberinsight: NiCurrentCarrierProperties
Information about the network number is currently connected to.
Fields
- network_code? string? - The https://en.wikipedia.org/wiki/Mobile_country_code for the carrier
numberis associated with. Unreal numbers are marked asunknownand the request is rejected altogether if the number is impossible according to the E.164 guidelines.
- name? string? - The full name of the carrier that
numberis associated with.
- country? string? - The country that
numberis associated with. This is in ISO 3166-1 alpha-2 format.
- network_type? string? - The type of network that
numberis associated with.
vonage.numberinsight: NiInitialCarrierProperties
Information about the network number was initially connected to.
Fields
- network_code? string? - The https://en.wikipedia.org/wiki/Mobile_country_code for the carrier
numberis associated with. Unreal numbers are marked asunknownand the request is rejected altogether if the number is impossible according to the E.164 guidelines.
- name? string? - The full name of the carrier that
numberis associated with.
- country? string? - The country that
numberis associated with. This is in ISO 3166-1 alpha-2 format.
- network_type? string? - The type of network that
numberis associated with.
vonage.numberinsight: NiResponseAsync
Fields
- request_id? string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- number? string - The
numberin your request
- remaining_balance? string - Your account balance in EUR after this request.
- request_price? string - If there is an internal lookup error, the
refund_pricewill reflect the lookup price. Ifcnamis requested for a non-US number therefund_pricewill reflect thecnamprice. If both of these conditions occur,refund_priceis the sum of the lookup price andcnamprice.
- status? NiStandardAdvancedStatus - Code | Text
- error_text? string - The status description of your request. Note: This field is equivalent to
status_messagefield in the other endpoints
vonage.numberinsight: NiResponseJsonAdvanced
Advanced
Fields
- status NiStandardAdvancedStatus - Code | Text
- status_message string - The status description of your request.
- request_id string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- international_format_number string - The
numberin your request in international format.
- national_format_number string - The
numberin your request in the format used by the country the number belongs to.
- country_code string - Two character country code for
number. This is in ISO 3166-1 alpha-2 format.
- country_code_iso3 string - Three character country code for
number. This is in ISO 3166-1 alpha-3 format.
- country_name string - The full name of the country that
numberis registered in.
- country_prefix string - The numeric prefix for the country that
numberis registered in.
- request_price? string - The amount in EUR charged to your account.
- refund_price? string - If there is an internal lookup error, the
refund_pricewill reflect the lookup price. Ifcnamis requested for a non-US number therefund_pricewill reflect thecnamprice. If both of these conditions occur,refund_priceis the sum of the lookup price andcnamprice.
- remaining_balance? string - Your account balance in EUR after this request.
- current_carrier? NiCurrentCarrierProperties - Information about the network
numberis currently connected to.
- original_carrier? NiInitialCarrierProperties - Information about the network
numberwas initially connected to.
- ported? string? - If the user has changed carrier for
number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
- caller_identity? NiCallerIdentity - Information about the network
numberis currently connected to.
- lookup_outcome? int - Shows if all information about a phone number has been returned. Possible values: Code | Text --- | --- 0 | Success 1 | Partial success - some fields populated 2 | Failed
- lookup_outcome_message? string - Shows if all information about a phone number has been returned.
- valid_number? string - Does
numberexist.unknownmeans the number could not be validated.validmeans the number is valid.not_validmeans the number is not valid.inferred_not_validmeans that the number could not be determined as valid or invalid via an external system and the best guess is that the number is invalid. This is applicable to mobile numbers only.
- reachable? string? - Can you call
numbernow. This is applicable to mobile numbers only.
vonage.numberinsight: NiResponseJsonBasic
Fields
- status? NiBasicStatus - Code | Text
- status_message? string - The status description of your request.
- request_id? string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- international_format_number? string - The
numberin your request in international format.
- national_format_number? string - The
numberin your request in the format used by the country the number belongs to.
- country_code? string - Two character country code for
number. This is in ISO 3166-1 alpha-2 format.
- country_code_iso3? string - Three character country code for
number. This is in ISO 3166-1 alpha-3 format.
- country_name? string - The full name of the country that
numberis registered in.
- country_prefix? string - The numeric prefix for the country that
numberis registered in.
vonage.numberinsight: NiResponseJsonStandard
Fields
- Fields Included from *NiResponseJsonBasic
- request_price? string - The amount in EUR charged to your account.
- refund_price? string - If there is an internal lookup error, the
refund_pricewill reflect the lookup price. Ifcnamis requested for a non-US number therefund_pricewill reflect thecnamprice. If both of these conditions occur,refund_priceis the sum of the lookup price andcnamprice.
- remaining_balance? string - Your account balance in EUR after this request.
- current_carrier? NiCurrentCarrierProperties - Information about the network
numberis currently connected to.
- original_carrier? NiInitialCarrierProperties - Information about the network
numberwas initially connected to.
- ported? string - If the user has changed carrier for
number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
- caller_identity? NiCallerIdentity - Information about the network
numberis currently connected to.
- caller_name? string - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- last_name? string - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- first_name? string - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- caller_type? string - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
vonage.numberinsight: NiResponseXmlAdvanced
Advanced
Fields
- request_id? string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- international_format_number? string - The
numberin your request in international format.
- local_number? NiresponsexmlbasicLocalNumber - An object containing the
numberin your request in the format used by the country the number belongs to.
- 'error? NiresponsexmlbasicError - The error code and status of your request
- request_price? string - If there is an internal lookup error, the
refund_pricewill reflect the lookup price. Ifcnamis requested for a non-US number therefund_pricewill reflect thecnamprice. If both of these conditions occur,refund_priceis the sum of the lookup price andcnamprice.
- remaining_balance? string - Your account balance in EUR after this request.
- current_carrier? NiCurrentCarrierProperties - Information about the network
numberis currently connected to.
- original_carrier? NiInitialCarrierProperties - Information about the network
numberwas initially connected to.
- ported? NiresponsexmladvancedPorted - If the user has changed carrier for
number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
- caller_identity? NiresponsexmladvancedCallerIdentity - Contains details of the number owner, if
cnamwas set totruein the request.
- caller_name? string - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- last_name? string - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- firs_name? string - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- caller_type? string - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- lookup_outcome? NiresponsexmladvancedLookupOutcome - An object indicating whether all information about a phone number has been returned.
- reachable? string - Can you call
numbernow. This is applicable to mobile numbers only.
- roaming? NiRoaming - Information about the roaming status for
number. This is applicable to mobile numbers only.
- valid_number? string - Does
numberexist.unknownmeans the number could not be validated.validmeans the number is valid.not_validmeans the number is not valid.inferred_not_validmeans that the number could not be determined as valid or invalid via an external system and the best guess is that the number is invalid. This is applicable to mobile numbers only.
- ip_warnings? string - This property is deprecated and can safely be ignored.
vonage.numberinsight: NiresponsexmladvancedCallerIdentity
Contains details of the number owner, if cnam was set to true in the request.
Fields
- callerType? string - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- callerName? string - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- firstName? string - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- lastName? string - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
vonage.numberinsight: NiresponsexmladvancedLookupOutcome
An object indicating whether all information about a phone number has been returned.
Fields
- code? decimal - Shows if all information about a phone number has been returned. Possible values: Code | Text -- | -- 0 | Success 1 | Partial success - some fields populated 2 | Failed
- lookup_outcome_message? string - Shows if all information about a phone number has been returned.
vonage.numberinsight: NiresponsexmladvancedPorted
If the user has changed carrier for number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
Fields
- ported_message? string - If the user has changed carrier for
number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
vonage.numberinsight: NiResponseXmlBasic
Basic
Fields
- request_id? string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- international_format_number? string - The
numberin your request in international format.
- local_number? NiresponsexmlbasicLocalNumber - An object containing the
numberin your request in the format used by the country the number belongs to.
- 'error? NiresponsexmlbasicError - The error code and status of your request
vonage.numberinsight: NiresponsexmlbasicError
The error code and status of your request
Fields
- code? string - The status code
- status_text? string - The status description of your request.
vonage.numberinsight: NiresponsexmlbasicLocalNumber
An object containing the number in your request in the format used by the country the number belongs to.
Fields
- country_code? string - Two character country code for
number. This is in ISO 3166-1 alpha-2 format.
- country_code_iso3? string - Three character country code for
number. This is in ISO 3166-1 alpha-3 format.
- country_name? string - The full name of the country that
numberis registered in.
- country_prefix? string - The numeric prefix for the country that
numberis registered in.
- number? string - The
numberin your request in the format used by the country the number belongs to.
vonage.numberinsight: NiResponseXmlStandard
Standard
Fields
- request_id? string - The unique identifier for your request. This is a alphanumeric string up to 40 characters.
- international_format_number? string - The
numberin your request in international format.
- local_number? NiresponsexmlbasicLocalNumber - An object containing the
numberin your request in the format used by the country the number belongs to.
- 'error? NiresponsexmlbasicError - The error code and status of your request
- request_price? string - If there is an internal lookup error, the
refund_pricewill reflect the lookup price. Ifcnamis requested for a non-US number therefund_pricewill reflect thecnamprice. If both of these conditions occur,refund_priceis the sum of the lookup price andcnamprice.
- remaining_balance? string - Your account balance in EUR after this request.
- current_carrier? NiCurrentCarrierProperties - Information about the network
numberis currently connected to.
- original_carrier? NiInitialCarrierProperties - Information about the network
numberwas initially connected to.
- ported? NiresponsexmlstandardPorted - If the user has changed carrier for number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported
- roaming? NiresponsexmlstandardRoaming - Information about the roaming status for number. This is applicable to mobile numbers only.
- caller_identity? NiresponsexmlstandardCallerIdentity - Contains details of the number owner, if
cnamwas set totruein the request.
vonage.numberinsight: NiresponsexmlstandardCallerIdentity
Contains details of the number owner, if cnam was set to true in the request.
Fields
- callerType? string - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- callerName? string - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- firstName? string - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- lastName? string - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- caller_name? string - Full name of the person or business who owns the phone number.
unknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
- last_name? string - Last name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- first_name? string - First name of the person who owns the phone number if the owner is an individual. This parameter is only present if
cnamhad a value oftruewithin the request.
- caller_type? string - The value will be
businessif the owner of a phone number is a business. If the owner is an individual the value will beconsumer. The value will beunknownif this information is not available. This parameter is only present ifcnamhad a value oftruewithin the request.
vonage.numberinsight: NiresponsexmlstandardPorted
If the user has changed carrier for number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported
Fields
- ported_message? string - If the user has changed carrier for
number. The assumed status means that the information supplier has replied to the request but has not said explicitly that the number is ported.
vonage.numberinsight: NiresponsexmlstandardRoaming
Information about the roaming status for number. This is applicable to mobile numbers only.
Fields
- status? string - Roaming status for number
vonage.numberinsight: NiRoaming
Information about the roaming status for number. This is applicable to mobile numbers only.
Fields
- status? string? - Is
numberoutside its home carrier network.
- roaming_network_code? string? - If
numberisroaming, this is the id of the carrier networknumberis roaming in.
- roaming_network_name? string? - If
numberisroaming, this is the name of the carrier networknumberis roaming in.
vonage.numberinsight: ProxyConfig
Proxy server configurations to be used with the HTTP client endpoint.
Fields
- host string(default "") - Host name of the proxy server
- port int(default 0) - Proxy server port
- userName string(default "") - Proxy server username
- password string(default "") - Proxy server password
Integer types
Import
import ballerinax/vonage.numberinsight;Metadata
Released date: 3 days ago
Version: 1.5.2
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.8.0
GraalVM compatible: Yes
Pull count
Total: 25
Current verison: 0
Weekly downloads
Keywords
Type/Connector
Vendor/Vonage
Area/Communication
Communication/Call Tracking
Cost/Paid
Contributors