Skip to content

Vonage Pricing

github-actions edited this page Jul 1, 2025 · 4 revisions

Documentation


Documentation / Vonage Pricing

Vonage Pricing SDK for Node.js

GitHub Workflow Status Codecov Latest Release Contributor Covenant License

Vonage

This is the Vonage Pricing SDK for Node.js for use with Vonage APIs. To use it you will need a Vonage account. Sign up for free at vonage.com.

For full API documentation refer to developer.nexmo.com.

If you are updating from V2 to V3, please check the migration guide found here

Installation

We recommend using this SDK as part of the overall @vonage/server-sdk package. Please see the main package for installation.

You can also use this SDK standalone if you only need access to just the Pricing API.

With NPM

npm install @vonage/pricing

With Yarn

yarn add @vonage/pricing

Usage

As part of the Vonage Server SDK

If you are using this SDK as part of the Vonage Server SDK, you can access it as the pricing property off of the client that you instantiate.

const { Vonage, Auth } = require('@vonage/server-sdk');

const credentials = new Auth({
  apiKey: API_KEY,
  apiSecret: API_SECRET
});
const options = {};
const vonage = new Vonage(credentials, options);

vonage.pricing.listCountryPricing('sms')
  .then(resp => console.log(resp))
  .catch(err => console.error(err));

Standalone

The SDK can be used standalone from the main Vonage Server SDK for Node.js if you only need to use the Pricing API. All you need to do is require('@vonage/pricing'), and use the returned object to create your own client.

const { Auth } = require('@vonage/auth');
const { Pricing } = require('@vonage/pricing');

const credentials = new Auth({
  apiKey: API_KEY,
  apiSecret: API_SECRET
});
const options = {};

const pricingClient = new Pricing(credentials, options);

Where credentials is any option from @vonage/auth, and options is any option from @vonage/server-client

Promises

Most methods that interact with the Vonage API uses Promises. You can either resolve these yourself, or use await to wait for a response.

const resp = await vonage.pricing.basicLookup(PHONE_NUMBER)

vonage.pricing.getAvailablePricing()
  .then(resp => console.log(resp))
  .catch(err => console.error(err));

Testing

Run:

npm run test

Enumerations

ServiceType

Defined in: pricing/lib/enums/ServiceType.ts:4

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

Defined in: pricing/lib/pricing.ts:39

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

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

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

Creates a new instance of the Client.

Parameters
credentials

The authentication credentials or an authentication instance.

AuthParams | AuthInterface

options?

ConfigParams

Optional configuration settings for the client.

Returns

Pricing

Inherited from

Client.constructor

Properties

auth
protected auth: AuthInterface;

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

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

Inherited from

Client.auth

authType
protected authType: AuthenticationType = AuthenticationType.BASIC;

Defined in: pricing/lib/pricing.ts:43

See

Client.authType

Overrides

Client.authType

config
protected config: ConfigParams;

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

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

Inherited from

Client.config

transformers
static transformers: object;

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

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

Methods

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

getConfig()
getConfig(): ConfigParams;

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

Returns

ConfigParams

Inherited from

Client.getConfig

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

Defined in: pricing/lib/pricing.ts:85

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}`);
}
listCountryPricing()
listCountryPricing(type, country): Promise<OutboundCountryPricingResponse>;

Defined in: pricing/lib/pricing.ts:60

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}`);
listPrefixPricing()
listPrefixPricing(type, prefix): Promise<OutboundAllCountriesPricingResponse>;

Defined in: pricing/lib/pricing.ts:108

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}`);
parseResponse()
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>;

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

Parses the response based on its content type.

Type Parameters
T

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

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

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

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

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

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

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

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

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

Sends a DELETE request to the specified URL.

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

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

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

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

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

Type Parameters
T

T

Parameters
method

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

POST | PUT | PATCH

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

Type Aliases

Network

type Network = object;

Defined in: pricing/lib/types/Network.ts:4

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

Properties

currency
currency: string;

Defined in: pricing/lib/types/Network.ts:18

The currency used for prices for this network

mcc
mcc: string;

Defined in: pricing/lib/types/Network.ts:23

The Mobile Country Code (MCC) of the operator

mnc
mnc: string;

Defined in: pricing/lib/types/Network.ts:28

The Mobile Network Code (MNC) of the operator

networkCode
networkCode: string;

Defined in: pricing/lib/types/Network.ts:33

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

networkName
networkName: string;

Defined in: pricing/lib/types/Network.ts:38

The company/organizational name of the operator

price
price: string;

Defined in: pricing/lib/types/Network.ts:13

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

type
type: string;

Defined in: pricing/lib/types/Network.ts:8

The type of network


OutboundAllCountriesPricingResponse

type OutboundAllCountriesPricingResponse = object;

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

Type representing the response for pricing information of all countries.

Properties

count
count: number;

Defined in: pricing/lib/types/Response/OutboundAllCountriesPricingResponse.ts:10

The number of countries in the response.

countries
countries: OutboundCountryPricingResponse[];

Defined in: pricing/lib/types/Response/OutboundAllCountriesPricingResponse.ts:15

An array of objects containing pricing information for individual countries.


OutboundCountryPricingResponse

type OutboundCountryPricingResponse = object;

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

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

Properties

countryCode
countryCode: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:9

Two-letter country code.

countryDisplayName
countryDisplayName: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:19

Readable country name.

countryName
countryName: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:14

Readable country name.

currency
currency: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:24

The currency that your account is being billed in.

defaultPrice
defaultPrice: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:29

The default price for services in this country.

dialingPrefix
dialingPrefix: string;

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:34

The dialing prefix for this country.

networks
networks: Network[];

Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:39

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


PricingClassParameters

type PricingClassParameters = AuthParams & VetchOptions & object;

Defined in: pricing/lib/types/PricingClassParameters.ts:7

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.

PricingResponse<T>

type PricingResponse<T> = VetchResponse<T>;

Defined in: pricing/lib/types/PricingResponse.ts:3

Type Parameters

T

T

Clone this wiki locally