Skip to content

THECALLR/sdk-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sdk-python

SDK in Python for CALLR API

Quick start

Install via PyPI

pip install callr

Or get sources from Github

Initialize your code

Pip

import callr
api = callr.Api("login", "password")

Source

import sys
sys.path.append("/path/to/callr_folder")
import callr
api = callr.Api("login", "password")

Exception Management

try:
	# Set your credentials
	api = callr.Api("login", "password")

	# This will raise an exception
	api.call("sms.send", "SMS")

# Exceptions handler
except (callr.CallrException, callr.CallrLocalException) as e:
	print "ERROR: %s" % e.code
	print "MESSAGE: %s" % e.msg
	print "DATA: ", e.data

Usage

Sending SMS

Without options

result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', None)

Method

Personalized sender

Your sender must have been authorized and respect the sms_sender format

result = api.call('sms.send', 'Your Brand', '+33123456789', 'Hello world!', None)

Method

If you want to receive replies, do not set a sender - we will automatically use a shortcode

result = api.call('sms.send', '', '+33123456789', 'Hello world!', None)

Method

Force GSM encoding

optionSMS = { 'force_encoding': 'GSM' }

result = api.call('sms.send', '', '+33123456789', 'Hello world!', optionSMS)

Method

Objects

Long SMS (availability depends on carrier)

text = ('Some super mega ultra long text to test message longer than 160 characters ' +
       'Some super mega ultra long text to test message longer than 160 characters ' +
       'Some super mega ultra long text to test message longer than 160 characters')
result = api.call('sms.send', 'SMS', '+33123456789', text, None)

Method

Specify your SMS nature (alerting or marketing)

optionSMS = { 'nature': 'ALERTING' }

result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)

Method

Objects

Custom data

optionSMS = { 'user_data': '42' }

result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)

Method

Objects

Delivery Notification - set URL to receive notifications

optionSMS = {
    'webhook': { 'endpoint': 'https://yourdomain.com/webhook_endpoint' }
}

result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)

Method

Objects

Get an SMS

result = api.call('sms.get', 'SMSHASH')

Method

Objects


REALTIME

Create a REALTIME app with a callback URL

options = {
    'url': 'https://yourdomain.com/realtime_callback_url'
}

result = api.call('apps.create', 'REALTIME10', 'Your app name', options)

Method

Objects

Start a REALTIME outbound call

target = {
    'number': '+33132456789',
    'timeout': 30
}

callOptions = {
    'cdr_field': '42',
    'cli': 'BLOCKED'
}

result = api.call('dialr/call.realtime', 'appHash', target, callOptions)

Method

Objects

Inbound Calls - Assign a phone number to a REALTIME app

result = api.call('apps.assign_did', 'appHash', 'DID ID')

Method

Objects


DIDs

List available countries with DID availability

result = api.call('did/areacode.countries')

Method

Objects

Get area codes available for a specific country and DID type

result = api.call('did/areacode.get_list', 'US', None)

Method

Objects

Get DID types available for a specific country

result = api.call('did/areacode.types', 'US')

Method

Objects

Buy a DID (after a reserve)

result = api.call('did/store.buy_order', 'OrderToken')

Method

Objects

Cancel your order (after a reserve)

result = api.call('did/store.cancel_order', 'OrderToken')

Method

Cancel a DID subscription

result = api.call('did/store.cancel_subscription', 'DID ID')

Method

View your store quota status

result = api.call('did/store.get_quota_status')

Method

Objects

Get a quote without reserving a DID

result = api.call('did/store.get_quote', 0, 'GOLD', 1)

Method

*Objects/

Reserve a DID

result = api.call('did/store.reserve', 0, 'GOLD', 1, 'RANDOM')

Method

Objects

View your order

result = api.call('did/store.view_order', 'OrderToken')

Method

Objects


Conferencing

Create a conference room

params = { 'open': True }
access = []

result = api.call('conference/10.create_room', 'room name', params, access)

Method

Objects

Assign a DID to a room

result = api.call('conference/10.assign_did', 'Room ID', 'DID ID')

Method

Create a PIN protected conference room

params = { 'open': True }
access = [
    { 'pin': '1234', 'level': 'GUEST' },
    { 'pin': '4321', 'level': 'ADMIN', 'phone_number': '+33123456789' }
]

result = api.call('conference/10.create_room', 'room name', params, access)

Method

Objects

Call a room access

result = api.call('conference/10.call_room_access', 'Room Access ID', 'BLOCKED', True)

Method


Media

List your medias

result = api.call('media/library.get_list', None)

Method

Create an empty media

result = api.call('media/library.create', 'name')

Method

Upload a media

media_id = 0

result = api.call('media/library.set_content', media_id, 'text', 'base64_audio_data')

Method

Use Text-to-Speech

media_id = 0

result = api.call('media/tts.set_content', media_id, 'Hello world!', 'TTS-EN-GB_SERENA', None)

Method


CDR

Get inbound or outbound CDRs

from = 'YYYY-MM-DD HH:MM:SS'
to = 'YYYY-MM-DD HH:MM:SS'

result = api.call('cdr.get', 'OUT', from, to, None, None)

Method

Objects


SENDR

Broadcast messages to a target (BETA)

target = {
    'number': '+33123456789',
    'timeout': 30
}

messages = [131, 132, 'TTS|TTS_EN-GB_SERENA|Hello world! how are you ? I hope you enjoy this call. good bye.']

options = {
    'cdr_field': 'userData',
    'cli': 'BLOCKED',
    'loop': 2
}

result = api.call('sendr/simple.broadcast_1', target, messages, options)
Without options
target = {
    'number': '+33123456789',
    'timeout': 30
}

messages = [131, 132, 134]

result = api.call('sendr/simple.broadcast_1', target, messages, None)

Method

Objects

Releases

No releases published

Packages

No packages published

Languages