These actions can be performed with the Phone Number API:

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

Prerequisites

  1. Sign up for a free Plivo trial account.
  2. Check out our server SDKs and install the SDK for the programming language you want to use.
  3. Buy a Plivo phone number. You need a Plivo phone number to receive calls. You can buy a Plivo phone number in more than 20 countries by visiting Phone Numbers > Buy Numbers in the Plivo console. Check the Voice API coverage page to see the supported countries.
  4. Use a web hosting service to host your web application. Many inexpensive cloud hosting providers charge just a few dollars a month. Follow the instructions of your hosting provider to host your web application.

Search for new numbers

This Phone Number API call lets you search for fixed, mobile, and toll-free numbers available on Plivo. You can search on any combination of the two-letter country code, number pattern, number type, and region. The call returns a list of numbers that match the search criteria and that are available to rent.

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

Code

import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.numbers.search(country_iso='GB')
print(response)

Rent a number

You can use a number you retrieve from the search above as input to rent the number for your Plivo account. Upon successful execution, the number will appear in your Plivo dashboard and be available for all the actions in the Number API.

POST https://api.plivo.com/v1/Account/{auth_id}/PhoneNumber/{number}/

Code

import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.numbers.buy(number='441273257545')
print(response)

Next step

Learn how to query the Pricing API.