Skip to content

Vonage JWT

github-actions edited this page Nov 12, 2024 · 62 revisions

Vonage JWTDocs


Documentation / Vonage JWT

Vonage JWT

Enumerations

CallerType

Enum representing the type of caller for a phone number.

Enumeration Members

Enumeration Member Value Description Defined in
BUSINESS "business" The value will be "business" if the owner of a phone number is a business. number-insights/lib/enums/CallerType.ts:13
CONSUMER "consumer" The value will be "consumer" if the owner of a phone number is an individual. number-insights/lib/enums/CallerType.ts:18
UNKNOWN "unknown" The value will be "unknown" if the information about the caller type is not available. number-insights/lib/enums/CallerType.ts:8

LookupOutcome

Enum representing the outcomes of a lookup operation.

Enumeration Members

Enumeration Member Value Description Defined in
FAILED 2 The lookup operation failed. number-insights/lib/enums/LookupOutcome.ts:18
PARTIAL_SUCCESS 1 The lookup operation partially succeeded. number-insights/lib/enums/LookupOutcome.ts:13
SUCCESS 0 The lookup operation was successful. number-insights/lib/enums/LookupOutcome.ts:8

NetworkType

Enum representing the type of network associated with a phone number.

Enumeration Members

Enumeration Member Value Description Defined in
LANDLINE "landline" The phone number is associated with a landline network. number-insights/lib/enums/NetworkType.ts:13
LANDLINE_PREMIUM "landline_premium" The phone number is associated with a premium landline network. number-insights/lib/enums/NetworkType.ts:18
LANDLINE_TOLLFREE "landline_tollfree" The phone number is associated with a toll-free landline network. number-insights/lib/enums/NetworkType.ts:23
MOBILE "mobile" The phone number is associated with a mobile network. number-insights/lib/enums/NetworkType.ts:8
PAGER "pager" The phone number is associated with a pager network. number-insights/lib/enums/NetworkType.ts:38
UNKNOWN "unknown" The type of network associated with the phone number is unknown. number-insights/lib/enums/NetworkType.ts:33
VIRTUAL "virtual" The phone number is associated with a virtual network. number-insights/lib/enums/NetworkType.ts:28

Reachable

Enum representing the reachability status of a phone number.

Enumeration Members

Enumeration Member Value Description Defined in
ABSENT "absent" The phone number's owner is absent. number-insights/lib/enums/Reachable.ts:23
BAD_NUMBER "bad_number" The phone number is invalid or a bad number. number-insights/lib/enums/Reachable.ts:28
BLACKLISTED "blacklisted" The phone number is blacklisted. number-insights/lib/enums/Reachable.ts:33
REACHABLE "reachable" The phone number is reachable. number-insights/lib/enums/Reachable.ts:13
UNDELIVERABLE "undeliverable" The phone number is undeliverable. number-insights/lib/enums/Reachable.ts:18
UNKNOWN "unknown" The reachability status is unknown. number-insights/lib/enums/Reachable.ts:8

ValidNumber

Enum representing the validity status of a phone number.

Enumeration Members

Enumeration Member Value Description Defined in
INFERRED "inferred" The validity of the phone number is inferred. number-insights/lib/enums/ValidNumber.ts:23
INFERRED_NOT_VALID "inferred_not_valid" The inferred validity of the phone number is not valid. number-insights/lib/enums/ValidNumber.ts:28
NOT_VALID "not_valid" The phone number is not valid. number-insights/lib/enums/ValidNumber.ts:18
UNKNOWN "unknown" The validity status is unknown. number-insights/lib/enums/ValidNumber.ts:8
VALID "valid" The phone number is valid. number-insights/lib/enums/ValidNumber.ts:13

Classes

NumberInsights

Client for the Vonage Number Insights API.

Examples

Create a standalone Number Insight client

import { NumberInsights } from '@vonage/numberInsight';

const numberInsightClient = new NumberInsights({
 apiKey: VONAGE_API_KEY,
 apiSecret: VONAGE_API_SECRET
});

Create an Number Insight client from the Vonage client

import { Vonage } from '@vonage/server-client';

const vonage = new Vonage({
  apiKey: VONAGE_API_KEY,
  apiSecret: VONAGE_API_SECRET
});

const numberInsightClient = vonage.numberInsight;

Extends

Constructors

new NumberInsights()
new NumberInsights(credentials, options?): NumberInsights

Creates a new instance of the Client.

Parameters

credentials: AuthInterface | AuthParams

The authentication credentials or an authentication instance.

options?: ConfigParams

Optional configuration settings for the client.

Returns

NumberInsights

Inherited from

Client.constructor

Defined in

server-client/dist/lib/client.d.ts:35

Properties

auth
protected auth: AuthInterface;

The authentication instance responsible for generating authentication headers and query parameters.

Inherited from

Client.auth

Defined in

server-client/dist/lib/client.d.ts:24

authType?
protected optional authType: AuthenticationType;

The type of authentication used for the client's requests.

Inherited from

Client.authType

Defined in

server-client/dist/lib/client.d.ts:20

config
protected config: ConfigParams;

Configuration settings for the client, including default hosts for various services and other request settings.

Inherited from

Client.config

Defined in

server-client/dist/lib/client.d.ts:28

transformers
static transformers: object;

Static property containing utility transformers.

camelCaseObjectKeys
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys
kebabCaseObjectKeys: PartialTransformFunction;
omit()
omit: (keys, obj) => TransformedObject;
Parameters

keys: string[]

obj: ObjectToTransform

Returns

TransformedObject

snakeCaseObjectKeys
snakeCaseObjectKeys: PartialTransformFunction;
Inherited from

Client.transformers

Defined in

server-client/dist/lib/client.d.ts:11

Methods

addAuthenticationToRequest()
addAuthenticationToRequest(request): Promise<VetchOptions>

Adds the appropriate authentication headers or parameters to the request based on the authentication type.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addAuthenticationToRequest

Defined in

server-client/dist/lib/client.d.ts:43

addBasicAuthToRequest()
protected addBasicAuthToRequest(request): Promise<VetchOptions>

Adds basic authentication headers to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addBasicAuthToRequest

Defined in

server-client/dist/lib/client.d.ts:71

addJWTToRequest()
protected addJWTToRequest(request): Promise<VetchOptions>

Adds a JWT to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addJWTToRequest

Defined in

server-client/dist/lib/client.d.ts:64

addQueryKeySecretToRequest()
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>

Adds API key and secret to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequest

Defined in

server-client/dist/lib/client.d.ts:57

addQueryKeySecretToRequestBody()
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>

Adds API key and secret to the request body.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequestBody

Defined in

server-client/dist/lib/client.d.ts:50

advancedLookup()
advancedLookup(phoneNumber, options?): Promise<AdvancedResponse>

Perform an advanced number lookup operation.

Parameters

phoneNumber: string

The phone number to perform the lookup for.

options?: AdvancedLookupOptions

Additional options for the lookup.

Returns

Promise<AdvancedResponse>

A promise that resolves to the advanced lookup response.

Example
const lookup = await numberInsightsClient.advancedLookup('15555551212');
console.log(`Ths number is ${lookup.valid_number}`);
Defined in

number-insights/lib/number-insights.ts:54

asyncAdvancedLookup()
asyncAdvancedLookup(
   phoneNumber, 
   callback, 
options?): Promise<AsyncAdvancedResponse>

Perform an asynchronous advanced number lookup operation.

Parameters

phoneNumber: string

The phone number to perform the lookup for.

callback: string

The callback URL for receiving the async lookup response.

options?: StandardLookupOptions

Additional options for the lookup.

Returns

Promise<AsyncAdvancedResponse>

A promise that resolves to the async advanced lookup response.

Examples
const lookup = await numberInsightsClient.asyncAdvancedLookup(
  '15555551212',
  'https://example.com/number-insights',
);
console.log(`The request ID is ${lookup.request_id}`);

Lookup with the CNAME option:

const lookup = await numberInsightsClient.asyncAdvancedLookup(
  '15555551212',
  'https://example.com/number-insights',
  { cname: true },
);
console.log(`The request ID is ${lookup.request_id}`);
Defined in

number-insights/lib/number-insights.ts:94

basicLookup()
basicLookup(phoneNumber, options?): Promise<BasicResponse>

Perform a basic number lookup operation.

Parameters

phoneNumber: string

The phone number to perform the lookup for.

options?: BasicLookupOptions

Additional options for the lookup.

Returns

Promise<BasicResponse>

A promise that resolves to the basic lookup response.

Examples
const lookup = await numberInsightsClient.basicLookup(
  '15555551212',
);
console.log(`The request ID is ${lookup.request_id}`);

Lookup with the country option:

const lookup = await numberInsightsClient.basicLookup(
  '15555551212',
  { country: 'US' },
);
console.log(`The request ID is ${lookup.request_id}`);
Defined in

number-insights/lib/number-insights.ts:132

getConfig()
getConfig(): ConfigParams
Returns

ConfigParams

Inherited from

Client.getConfig

Defined in

server-client/dist/lib/client.d.ts:36

parseResponse()
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>

Parses the response based on its content type.

Type Parameters

T

The expected type of the parsed response data.

Parameters

request: VetchOptions

The request options.

response: Response

The raw response from the request.

Returns

Promise<VetchResponse<T>>

  • The parsed response.
Inherited from

Client.parseResponse

Defined in

server-client/dist/lib/client.d.ts:168

prepareBody()
protected prepareBody(request): undefined | string

Prepares the body for the request based on the content type.

Parameters

request: VetchOptions

The request options.

Returns

undefined | string

  • The prepared request body as a string or undefined.
Inherited from

Client.prepareBody

Defined in

server-client/dist/lib/client.d.ts:158

prepareRequest()
protected prepareRequest(request): Promise<VetchOptions>

Prepares the request with necessary headers, authentication, and query parameters.

Parameters

request: VetchOptions

The initial request options.

Returns

Promise<VetchOptions>

  • The modified request options.
Inherited from

Client.prepareRequest

Defined in

server-client/dist/lib/client.d.ts:151

sendDeleteRequest()
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>

Sends a DELETE request to the specified URL.

Type Parameters

T

Parameters

url: string

The URL endpoint for the DELETE request.

Returns

Promise<VetchResponse<T>>

  • The response from the DELETE request.
Inherited from

Client.sendDeleteRequest

Defined in

server-client/dist/lib/client.d.ts:78

sendFormSubmitRequest()
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a POST request with form data to the specified URL.

Type Parameters

T

Parameters

url: string

The URL endpoint for the POST request.

payload?: Record<string, undefined | string>

Optional payload containing form data to send with the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendFormSubmitRequest

Defined in

server-client/dist/lib/client.d.ts:86

sendGetRequest()
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>

Sends a GET request to the specified URL with optional query parameters.

Type Parameters

T

Parameters

url: string

The URL endpoint for the GET request.

queryParams?

Optional query parameters to append to the URL. These should be compatible with Node's URLSearchParams.

Returns

Promise<VetchResponse<T>>

  • The response from the GET request.
Inherited from

Client.sendGetRequest

Defined in

server-client/dist/lib/client.d.ts:94

sendPatchRequest()
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a PATCH request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the PATCH request.

payload?

Optional payload to be sent as the body of the PATCH request.

Returns

Promise<VetchResponse<T>>

  • The response from the PATCH request.
Inherited from

Client.sendPatchRequest

Defined in

server-client/dist/lib/client.d.ts:104

sendPostRequest()
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a POST request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the POST request.

payload?

Optional payload to be sent as the body of the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendPostRequest

Defined in

server-client/dist/lib/client.d.ts:114

sendPutRequest()
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a PUT request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the PUT request.

payload?

Optional payload to be sent as the body of the PUT request.

Returns

Promise<VetchResponse<T>>

  • The response from the PUT request.
Inherited from

Client.sendPutRequest

Defined in

server-client/dist/lib/client.d.ts:124

sendRequest()
sendRequest<T>(request): Promise<VetchResponse<T>>

Sends a request adding necessary headers, handling authentication, and parsing the response.

Type Parameters

T

Parameters

request: VetchOptions

The options defining the request, including URL, method, headers, and data.

Returns

Promise<VetchResponse<T>>

  • The parsed response from the request.
Inherited from

Client.sendRequest

Defined in

server-client/dist/lib/client.d.ts:144

sendRequestWithData()
sendRequestWithData<T>(
   method, 
   url, 
payload?): Promise<VetchResponse<T>>

Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.

Type Parameters

T

Parameters

method: POST | PUT | PATCH

The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).

url: string

The URL endpoint for the request.

payload?

Optional payload to be sent as the body of the request, JSON-encoded.

Returns

Promise<VetchResponse<T>>

  • The response from the request.
Inherited from

Client.sendRequestWithData

Defined in

server-client/dist/lib/client.d.ts:135

standardLookup()
standardLookup(phoneNumber, options?): Promise<StandardResponse>

Perform a standard number lookup operation.

Parameters

phoneNumber: string

The phone number to perform the lookup for.

options?: StandardLookupOptions

Additional options for the lookup.

Returns

Promise<StandardResponse>

A promise that resolves to the standard lookup response.

Examples
const lookup = await numberInsightsClient.standardLookup(
  '15555551212',
);
console.log(`The request ID is ${lookup.request_id}`);

Lookup with the cname option:

const lookup = await numberInsightsClient.standardLookup(
  '15555551212',
  { cname: true },
);
console.log(`The request ID is ${lookup.request_id}`);
Defined in

number-insights/lib/number-insights.ts:169

Type Aliases

AdvancedLookupOptions

type AdvancedLookupOptions: StandardLookupOptions & object;

Interface representing advanced lookup options for a phone number lookup operation.

Type declaration

real_time_data?
optional real_time_data: boolean;

Indicates whether real-time data should be included in the lookup. If true, real-time data is included; otherwise, it's not included.

Defined in

number-insights/lib/types/AdvancedLookupOptions.ts:6


AdvancedResponse

type AdvancedResponse: StandardResponse & object;

Type representing an advanced response from a phone number lookup operation.

Type declaration

lookup_outcome
lookup_outcome: LookupOutcome;

The outcome of the lookup operation, represented by a LookupOutcome enum value.

lookup_outcome_message
lookup_outcome_message: string;

A message describing the outcome of the lookup operation.

reachable
reachable: Reachable;

The reachability status of the phone number, represented by a Reachable enum value.

real_time_data
real_time_data: RealTimeDataResponse;

Real-time data related to the phone number.

roaming
roaming: RoamingDataResponse | string;

Information about the roaming status of the phone number.

valid_number
valid_number: ValidNumber;

The validity status of the phone number, represented by a ValidNumber enum value.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/AdvancedResponse.ts:18


AsyncAdvancedLookupOptions

type AsyncAdvancedLookupOptions: StandardLookupOptions & object;

Interface representing asynchronous advanced lookup options for a phone number lookup operation.

Type declaration

callback
callback: string;

The callback URL to which the lookup response will be sent asynchronously.

Defined in

number-insights/lib/types/AsyncAdvancedLookupOptions.ts:6


AsyncAdvancedResponse

type AsyncAdvancedResponse: object;

Type representing an asynchronous advanced response from a phone number lookup operation. This response may include additional details about the request and its status.

Type declaration

error_text
error_text: string;

Any error text or message associated with the response.

number
number: string;

The phone number associated with the response.

remaining_balance
remaining_balance: string;

Your account balance in EUR after this request.

request_id
request_id: string;

The unique identifier for the request.

request_price
request_price: string;

The amount in EUR charged to your account for this request.

status
status: number;

The status code of the response.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/AsyncAdvancedResponse.ts:9


BasicLookupOptions

type BasicLookupOptions: object;

Basic lookup options for a phone number lookup operation.

Type declaration

country?
optional country: string;

The two-character country code for the phone number's country.

Defined in

number-insights/lib/types/BasicLookupOptions.ts:4


BasicResponse

type BasicResponse: object;

Type representing a basic response from a phone number lookup operation.

Type declaration

country_code
country_code: string;

The two-character country code for the phone number.

country_code_iso3
country_code_iso3: string;

The three-character country code for the phone number.

country_name
country_name: string;

The full name of the country that the phone number is registered in.

country_prefix
country_prefix: string;

The numeric prefix for the country that the phone number is registered in.

international_format_number
international_format_number: string;

The phone number in international format.

national_format_number
national_format_number: string;

The phone number in the format used by the country.

request_id
request_id: string;

The unique identifier for the request.

status
status: number;

The status code of the response.

status_message
status_message: string;

The status message of the response.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/BasicResponse.ts:8


CallerIdentityResponse

type CallerIdentityResponse: object;

Type representing the identity of a caller.

Type declaration

caller_name
caller_name: string;

The caller's name.

caller_type
caller_type: CallerType;

The type of the caller, either "business," "consumer," or "unknown."

first_name
first_name: string;

The caller's first name.

last_name
last_name: string;

The caller's last name.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/CallerIdentityResponse.ts:10


CarrierInfoResponse

type CarrierInfoResponse: object;

Type representing carrier information.

Type declaration

country
country: string;

The country in which the carrier operates.

name
name: string;

The full name of the carrier.

network_code
network_code: string;

The network code associated with the carrier.

network_type
network_type: NetworkType;

The type of network associated with the carrier.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/CarrierInforResponse.ts:10


NumberInsightsResponse<T>

type NumberInsightsResponse<T>: VetchResponse<T>;

Interface representing a response from a number insights operation. This extends the VetchResponse<T> interface.

Type Parameters

T

Defined in

number-insights/lib/types/NumberInsightsResponse.ts:7


RealTimeDataResponse

type RealTimeDataResponse: object;

Type representing real-time data related to a phone number.

Type declaration

active_status
active_status: string;
handset_status
handset_status: string;

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/RealTimeDataResponse.ts:8


RoamingDataResponse

type RoamingDataResponse: object;

Type representing information about the roaming status of a phone number.

Type declaration

roaming_country_code
roaming_country_code: string;
roaming_network_code
roaming_network_code: string;
roaming_network_name
roaming_network_name: string;
status
status: string;

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/RoamingDataResponse.ts:8


StandardLookupOptions

type StandardLookupOptions: BasicLookupOptions & object;

Interface representing standard lookup options for a phone number lookup operation.

Type declaration

cname?
optional cname: boolean;

Indicates whether caller name (CNAME) information should be included in the lookup. If true, CNAME information is included; otherwise, it's not included.

Defined in

number-insights/lib/types/StandardLookupOptions.ts:6


StandardResponse

type StandardResponse: BasicResponse & object;

Type representing a standard response from a phone number lookup operation. This response includes various details such as pricing, carrier information, porting status, and caller identity.

Type declaration

caller_identity
caller_identity: CallerIdentityResponse;

Information about the caller's identity.

caller_name
caller_name: string;

Full name of the person or business who owns the phone number.

caller_type
caller_type: CallerType;

The type of caller, either "business," "consumer," or "unknown."

country_code
country_code: string;

The two-character country code for the phone number.

country_code_iso3
country_code_iso3: string;

The three-character country code for the phone number.

country_name
country_name: string;

The full name of the country that the phone number is registered in.

country_prefix
country_prefix: string;

The numeric prefix for the country that the phone number is registered in.

current_carrier
current_carrier: CarrierInfoResponse;

Information about the current carrier of the phone number.

first_name
first_name: string;

First name of the person who owns the phone number.

international_format_number
international_format_number: string;

The phone number in international format.

last_name
last_name: string;

Last name of the person who owns the phone number.

national_format_number
national_format_number: string;

The phone number in the format used by the country.

original_carrier
original_carrier: CarrierInfoResponse;

Information about the original carrier of the phone number.

ported
ported: string;

Porting status of the phone number.

refund_price
refund_price: string;

The refund amount in EUR, reflecting lookup and CNAM pricing.

remaining_balance
remaining_balance: string;

Your account balance in EUR after this request.

request_id
request_id: string;

The unique identifier for the request.

request_price
request_price: string;

The price charged for the request in EUR.

status
status: number;

The status code of the response.

status_message
status_message: string;

The status message of the response.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

number-insights/lib/types/Responses/StandardResponse.ts:14

Clone this wiki locally