Skip to content

Vonage Pricing

github-actions edited this page Oct 17, 2024 · 56 revisions

Vonage PricingDocs


Documentation / Vonage Pricing

Vonage Pricing

Enumerations

ServiceType

Enum representing different service types for pricing information.

Enumeration Members

Enumeration Member Value Description Defined in
SMS "sms" SMS service. pricing/lib/enums/ServiceType.ts:8
SMS_TRANSIT "sms-transit" SMS Transit service. pricing/lib/enums/ServiceType.ts:13
VOICE "voice" Voice service. pricing/lib/enums/ServiceType.ts:18

Classes

Pricing

The Pricing API allows you to retrieve pricing information for all countries and a specific service type, for a specific country and service type, or for a specific prefix and service type.

Examples

Create a standalone Pricing client

import { Pricing } from '@vonage/pricing';

const pricingClient = new Pricing({
 apiKey: VONAGE_API_KEY,
 apiSecret: VONAGE_API_SECRET
});

Create an Pricing client from the Vonage client

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

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

const pricingClient = vonage.pricing;

Extends

Constructors

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

Creates a new instance of the Client.

Parameters

credentials: AuthParams | AuthInterface

The authentication credentials or an authentication instance.

options?: ConfigParams

Optional configuration settings for the client.

Returns

Pricing

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 authType: AuthenticationType = AuthenticationType.QUERY_KEY_SECRET;

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

Overrides

Client.authType

Defined in

pricing/lib/pricing.ts:40

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

getConfig()
getConfig(): ConfigParams
Returns

ConfigParams

Inherited from

Client.getConfig

Defined in

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

listAllCountriesPricing()
listAllCountriesPricing(type): Promise<OutboundAllCountriesPricingResponse>

Retrieves pricing information for all countries and a specific service type.

Parameters

type: ServiceType

The service type.

Returns

Promise<OutboundAllCountriesPricingResponse>

  • Pricing information for all countries.
Example
import { ServiceType } from '@vonage/pricing';

const pricing = await pricingClient.listAllCountriesPricing(ServiceType.SMS);
for (const country in pricing.countries) {
 console.log(`The current price for ${country.countryName} is ${country.defaultPrice}`);
}
Defined in

pricing/lib/pricing.ts:82

listCountryPricing()
listCountryPricing(type, country): Promise<OutboundCountryPricingResponse>

Retrieves pricing information for a specific country and service type.

Parameters

type: ServiceType

The service type.

country: string

The country for which pricing information is requested.

Returns

Promise<OutboundCountryPricingResponse>

  • Pricing information for the specified country.
Example
import { ServiceType } from '@vonage/pricing';

const pricing = await pricingClient.listCountryPricing(ServiceType.SMS, 'GB');
console.log(`The current price for Great Britian is ${pricing.defaultPrice}`);
Defined in

pricing/lib/pricing.ts:57

listPrefixPricing()
listPrefixPricing(type, prefix): Promise<OutboundAllCountriesPricingResponse>

Retrieves pricing information for a specific prefix and service type.

Parameters

type: ServiceType

The service type.

prefix: string

The prefix for which pricing information is requested.

Returns

Promise<OutboundAllCountriesPricingResponse>

  • Pricing information for the specified prefix.
Example
import { ServiceType } from '@vonage/pricing';

const pricing = await pricingClient.listPrefixPricing(ServiceType.SMS, '44');
console.log(`The current price for Great Britian is ${pricing.defaultPrice}`);
Defined in

pricing/lib/pricing.ts:105

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, 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

Type Aliases

Network

type Network: object;

Type representing a network within a specific country's pricing information.

Type declaration

currency
currency: string;

The currency used for prices for this network

mcc
mcc: string;

The Mobile Country Code (MCC) of the operator

mnc
mnc: string;

The Mobile Network Code (MNC) of the operator

networkCode
networkCode: string;

The Mobile Country Code and Mobile Network Code combined to give a unique reference for the operator

networkName
networkName: string;

The company/organizational name of the operator

price
price: string;

The cost to send a message or make a call on this network.

type
type: string;

The type of network

Defined in

pricing/lib/types/Network.ts:4


OutboundAllCountriesPricingResponse

type OutboundAllCountriesPricingResponse: object;

Type representing the response for pricing information of all countries.

Type declaration

count
count: number;

The number of countries in the response.

countries
countries: OutboundCountryPricingResponse[];

An array of objects containing pricing information for individual countries.

Defined in

pricing/lib/types/Response/OutboundAllCountriesPricingResponse.ts:6


OutboundCountryPricingResponse

type OutboundCountryPricingResponse: object;

Type representing the response for pricing information of a specific country.

Type declaration

countryCode
countryCode: string;

Two-letter country code.

countryDisplayName
countryDisplayName: string;

Readable country name.

countryName
countryName: string;

Readable country name.

currency
currency: string;

The currency that your account is being billed in.

defaultPrice
defaultPrice: string;

The default price for services in this country.

dialingPrefix
dialingPrefix: string;

The dialing prefix for this country.

networks
networks: Network[];

An array of network objects representing different networks in this country.

Defined in

pricing/lib/types/Response/OutboundCountryPricingResponse.ts:5


PricingClassParameters

type PricingClassParameters: AuthParams & VetchOptions & object;

Type representing parameters for a pricing class, including authentication and Vetch options.

Type declaration

auth?
optional auth: AuthInterface;

An optional authentication interface.

Returns
  • The authentication interface if provided, otherwise undefined.

Defined in

pricing/lib/types/PricingClassParameters.ts:7


PricingResponse<T>

type PricingResponse<T>: VetchResponse<T>;

Type Parameters

T

Defined in

pricing/lib/types/PricingResponse.ts:3

Clone this wiki locally