Python Helper

The Plivo Python helper simplifies the process of making Plivo API calls and generating Plivo XML. Please note that this is the legacy version.

If you are looking for the latest version, you can get it here.

Prerequisites

  • Python >= 2.5
  • Pip - a tool for installing and managing Python packages.

Installation

Quick Installation

Run the following command for a quick installation of the Python helper.

$ pip install plivo

Manual Installation

Install the helper manually from Github.

$ git clone git://github.com/plivo/plivo-python.git
$ python setup.py install

Using the library

Initializing the RestAPI client

You can use plivo.RestAPI to initialize a REST client that can make API requests to Plivo.

1
2
3
auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

Send an SMS

The snippet below shows how you can send an SMS.

1
2
3
4
5
6
7
params = {
    'src': '1111111111',
    'dst' : '2222222222',
    'text' : u"Hello, how are you?"
}

response = p.send_message(params)

Check out Message API documentation for more details.

Make an Outbound Phone Call

You can make outbound phone calls to landlines, mobiles, and SIP endpoints (e.g., softphones), in any of our 200+ coverage countries

1
2
3
4
5
6
7
8
params = {
    'to': '2222222222',
    'from' : '1111111111',
    'answer_url' : "https://s3.amazonaws.com/static.plivo.com/answer.xml",
    'answer_method' : "GET"
}

response = p.make_call(params)

Check out Call API documentation for more details.

Examples

Take a look at the Python examples on GitHub.

Reporting Issues

Please report issues or submit patches using the Github Issue Tracker or Customer Support.

License

The Plivo Python Helper Library is written by the Plivo Team and is distributed under the MIT License.