Pricing API

The pricing API lets you retrieve a rates for a country for both inbound and outbound calls.

The following actions can be performed using the Endpoint API:

BaseURI: https://api.plivo.com/v1/Account/{auth_id}/Pricing/

Prerequisites

  1. Sign up for a free Plivo trial account.
  2. Check out our Helper Libraries page and install the right helper based on the programming language you want to use.
  3. Buy a Plivo phone number. A phone number is required to receive calls. You can buy a Plivo phone number in over 20+ countries through the Buy Numbers tab on your Plivo account UI. Check the Voice API coverage page for all the supported countries.
  4. Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.

Get Pricing for a Country

This API lets you get pricing details for a specific country.

GET https://api.plivo.com/v1/Account/{auth_id}/Pricing/

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"

p = plivo.RestAPI(auth_id, auth_token)

# Search for new number
params = {
    'country_iso': 'US', # The ISO code A2 of the country
    'type' : 'local', # The type of number you are looking for. The possible number types are local, national and tollfree.
    'pattern' : '210', # Represents the pattern of the number to be searched. 
    'region' : 'Texas' # This filter is only applicable when the number_type is local. Region based filtering can be performed.
}

response = p.search_phone_numbers(params)
print str(response)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"


p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Search for new number
params = {
    'country_iso' => 'US', # The ISO code A2 of the country
    'type' => 'local', # The type of number you are looking for. The possible number types are local, national and tollfree.
    'pattern' => '210', # Represents the pattern of the number to be searched. 
    'region' => 'Texas' # This filter is only applicable when the number_type is local. Region based filtering can be performed.
}

response = p.search_phone_number(params)
print response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
var plivo = require('plivo');
var p = plivo.RestAPI({
  authId: 'Your AUTH_ID',
  authToken: 'Your AUTH_TOKEN'
});

// Search for new number
var params = { 
    'country_iso': 'US', // The ISO code A2 of the country
    'type' : 'local', // The type of number you are looking for. The possible number types are local, national and tollfree.
    'pattern' : '210', // Represents the pattern of the number to be searched. 
    'region' : 'Texas' // This filter is only applicable when the number_type is local. Region based filtering can be performed.
};

p.search_phone_numbers(params, function (status, response) {
    console.log('Status: ', status);
    console.log('API Response:\n', response);
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;
    
    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    
    $p = new RestAPI($auth_id, $auth_token);
    
    # Search for new number
    $params = array(
        'country_iso' => 'US', # The ISO code A2 of the country
        'type' => 'local', # The type of number you are looking for. The possible number types are local, national and tollfree.
        'pattern' => '210', # Represents the pattern of the number to be searched. 
        'region' => 'Texas' # This filter is only applicable when the number_type is local. Region based filtering can be performed.
    );
    $response = $p->search_phone_numbers($params);
    print_r ($response);  
?>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package plivoexample;

import java.util.LinkedHashMap;

import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.number.NumberSearchFactory;
import com.plivo.helper.exception.PlivoException;

public class App {

    public static void main(String[] args) throws IllegalAccessException {

        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        // Search for a phone number
        LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
        parameters.put("country_iso","US");
        parameters.put("type","local");
        parameters.put("pattern","210");
        parameters.put("region","Texas");

        try {
            PhoneNumberSearchFactory resp = api.searchPhoneNumber(parameters);
            System.out.println(resp);
        }catch (PlivoException e){  
            System.out.println(e.getLocalizedMessage());
        } 
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
            
            // Search for a new phone number
            IRestResponse<PhoneNumberList> resp = plivo.search_phone_numbers(new Dictionary<string,string>()
            {
                {"country_iso","US"}, // The ISO code A2 of the country
                {"type","local"}, // The type of number you are looking for. The possible number types are local, national and tollfree.
                {"pattern","210"}, // Represents the pattern of the number to be searched.
                {"region","Texas"} // This filter is only applicable when the number_type is local. Region based filtering can be performed.
            });

            Console.WriteLine(resp.Content);
        }
    }
}
1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/PhoneNumber/?country_iso=US&type=local&pattern=210&region=Texas

Sample Response

(200, {
        u'country': u'Qatar', 
        u'api_id': u'0f1755c6-d156-11e4-b423-22000ac8a2f8', 
        u'country_code': 974, 
        u'country_iso': u'QA', 
        u'message': {
            u'inbound': {u'rate': None}, 
            u'outbound': {u'rate': u'0.03800'}, 
            u'outbound_networks_list': [
                {u'rate': u'0.03800', u'group_name': u'Qatar - All'}
            ]
        }, 
        u'voice': {
            u'inbound': {
                u'ip': {u'rate': u'0.00300'}, 
                u'local': {u'rate': None}, 
                u'tollfree': {u'rate': None}
            }, 
            u'outbound': {
                u'ip': {u'rate': u'0.00300'}, 
                u'local': {u'rate': u'0.20990'}, 
                u'tollfree': {u'rate': None}, 
                u'rates': [
                    {u'prefix': [u'974'], u'rate': u'0.20990'}, 
                    {u'prefix': [u'974124', u'9742', u'9743', u'97430', u'9745', u'9746', u'9747', u'97470', u'97474', u'97477'], u'rate': u'0.24480'}
                ]
            }
        }, 
        u'phone_numbers': {
            u'local': {u'rate': None}, 
            u'tollfree': {u'rate': None}
        }
    }
)

Next Step

Learn how to Paginate API requests.

  1. Account API
  2. Application API
  3. Endpoint API
  4. Number API
  5. Phone Number API
  6. Pricing API
  7. API Pagination