All Projects → plivo → plivo-python

plivo / plivo-python

Licence: MIT license
A Python library for communicating with the Plivo API and generating Plivo XML.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to plivo-python

Vonage Python Sdk
Vonage Server SDK for Python. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 134 (+135.09%)
Mutual labels:  messaging, voice
ios-swift-chat-ui-kit
Ready-to-use Chat UI Components for Swift (iOS)
Stars: ✭ 42 (-26.32%)
Mutual labels:  messaging, voice
ios-swift-chat-app
Open-source Voice & Video Calling and Text Chat App for Swift (iOS)
Stars: ✭ 111 (+94.74%)
Mutual labels:  messaging, voice
Vonage Php Sdk Core
Vonage REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 849 (+1389.47%)
Mutual labels:  messaging, voice
Android Kotlin Chat App
Open-source Voice & Video Calling and Text Chat App for Kotlin (Android)
Stars: ✭ 76 (+33.33%)
Mutual labels:  messaging, voice
Android Java Chat App
Open-source Voice & Video Calling and Text Chat App for Java (Android)
Stars: ✭ 66 (+15.79%)
Mutual labels:  messaging, voice
Vonage Node Sdk
Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 323 (+466.67%)
Mutual labels:  messaging, voice
Vonage Java Sdk
Vonage Server SDK for Java. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 75 (+31.58%)
Mutual labels:  messaging, voice
Vonage Ruby Sdk
Vonage REST API client for Ruby. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 203 (+256.14%)
Mutual labels:  messaging, voice
go-nats-examples
Single repository for go-nats example code. This includes all documentation examples and any common message pattern examples.
Stars: ✭ 99 (+73.68%)
Mutual labels:  messaging
amqv7-workshop
No description or website provided.
Stars: ✭ 22 (-61.4%)
Mutual labels:  messaging
disgo
A modular Golang Discord API Wrapper
Stars: ✭ 113 (+98.25%)
Mutual labels:  voice
UniSpySDK
Updated and Cleaned GameSpy SDK
Stars: ✭ 31 (-45.61%)
Mutual labels:  voice
Whatsapp Android App
This is sample code for layout for chatting app like Whatsapp.
Stars: ✭ 32 (-43.86%)
Mutual labels:  messaging
minority
Ethereum 2.0 node multiplexer between consensus and execution
Stars: ✭ 94 (+64.91%)
Mutual labels:  messaging
muon-java
Muon Core for the JVM. APIs and Microservices taken to the next level
Stars: ✭ 18 (-68.42%)
Mutual labels:  messaging
tvoip
Terminal-based P2P VoIP application (TeamSpeak-/Skype-like voice chatting over LAN or Internet)
Stars: ✭ 34 (-40.35%)
Mutual labels:  voice
simplex-chat
SimpleX - the first messaging platform operating without user identifiers of any kind - 100% private by design! iOS and Android apps are released 📱!
Stars: ✭ 1,975 (+3364.91%)
Mutual labels:  messaging
SuperSimpleTcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 263 (+361.4%)
Mutual labels:  messaging
speaker.app
Source code for https://speaker.app, a batteries-included, web-based, quasi-decentralized, WebRTC networking platform, with a primary focus on audio and screen-sharing, and a secondary focus on chat messages and peripheral features.
Stars: ✭ 26 (-54.39%)
Mutual labels:  voice

plivo-python

UnitTests PyPI PyPI codecov PyPI

The Plivo Python SDK makes it simpler to integrate communications into your Python applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows.

Installation

Install the SDK using pip

pip install plivo

If you have the 0.11.3 version (a.k.a legacy) already installed, you will have to first uninstall it before installing the new version. pip install --upgrade plivo might not work depending on your system status.

Alternatively, you can download the source code from this repo(master branch) and run

python setup.py install

For features in beta, use the beta branch:

pip install plivo==4.2.0b1

Alternatively, you can download the source code from this repo(beta branch) and run

python setup.py install

We recommend that you use virtualenv to manage and segregate your Python environments, instead of using sudo with your commands and overwriting dependencies.

Getting started

Authentication

To make the API requests, you need to create a RestClient and provide it with authentication credentials (which can be found at https://manage.plivo.com/dashboard/).

We recommend that you store your credentials in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables, so as to avoid the possibility of accidentally committing them to source control. If you do this, you can initialise the client with no arguments and it will automatically fetch them from the environment variables:

import plivo

client = plivo.RestClient()

Alternatively, you can specifiy the authentication credentials while initializing the RestClient.

import plivo

client = plivo.RestClient(auth_id='your_auth_id', auth_token='your_auth_token')

If you expect to make a large number of API requests, re-use the same client instance, but if you expect to create a client on an on-demand basis, you can use a context manager to automatically frees all resources used by the client

import plivo

with plivo.RestClient() as client:
  pass # Do something with the client

The basics

The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:

client.resources.create(*args, **kwargs) # Create
client.resources.get(id=resource_identifier) # Get
client.resources.update(id=resource_identifier, *args, **kwargs) # Update
client.resources.delete(id=resource_identifier) # Delete
client.resources.list() # List all resources, max 20 at a time

You can also use the resource directly to update and delete it. For example,

resource = client.resources.get(id=resource_identifier)
resource.update(*args, **kwargs) # update the resource
resource.delete() # Delete the resource

Also, using client.resources.list() would list the first 20 resources by default (which is the first page, with limit as 20, and offset as 0). To get more, you will have to use limit and offset to get the second page of resources.

To list all resources, you can simply use the following pattern that will handle the pagination for you automatically, so you won't have to worry about passing the right limit and offset values.

for resource in client.resources:
    print(resource.id)

Examples

Send a message

import plivo

client = plivo.RestClient()
message_created = client.messages.create(
    src='the_source_number',
    dst='the_destination_number',
    text='Hello, world!'
)

Make a call

import plivo

client = plivo.RestClient()
call_made = client.calls.create(
    from_='the_from_number',
    to_='the_to_number',
    answer_url='https://answer.url'
)

Lookup a number

import plivo

client = plivo.RestClient(auth_id='', auth_token='')
resp = client.lookup.get("<insert-number-here>")
print(resp)

Generate Plivo XML

from plivo import plivoxml

xml_response = plivoxml.ResponseElement()
xml_response.add_speak('Hello, world!') # or add(plivoxml.SpeakElement(text))

print(xml_response.to_string())

This generates the following XML:

<Response>
  <Speak>Hello, world!</Speak>
</Response>

Run a PHLO

import plivo

auth_id = '<auth_id>'
auth_token = '<auth_token>'
phlo_id = '<phlo_id' # https://console.plivo.com/phlo/list/
phlo_client = plivo.phlo.RestClient(auth_id=auth_id, auth_token=auth_token)
phlo = phlo_client.phlo.get(phlo_id)
response = phlo.run()
print(response)

More examples

Refer to the Plivo API Reference for more examples. Also refer to the guide to setting up dev environment on Plivo Developers Portal to setup a Flask server & use it to test out your integration in under 5 minutes. to get started with Plivo.

Reporting issues

Report any feedback or problems with this version by opening an issue on Github.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].