v14 -> v15
Client Initialization
- v14
- v15-beta
from bandwidth.bandwidth_client import BandwidthClient
from bandwidth.exceptions.api_exception import APIException
bandwidth_client = BandwidthClient(
voice_basic_auth_user_name='username',
voice_basic_auth_password='password',
messaging_basic_auth_user_name='username',
messaging_basic_auth_password='password',
multi_factor_auth_basic_auth_user_name='username',
multi_factor_auth_basic_auth_password='password',
phone_number_lookup_basic_auth_user_name='username',
phone_number_lookup_basic_auth_password='password'
)
account_id = "5500000"
import bandwidth
configuration = bandwidth.Configuration(
username = 'API_USERNAME',
password = 'API_PASSWORD'
)
api_client = bandwidth.ApiClient(configuration)
account_id = "5500000"
Messaging
Create Message
- v14
- v15-beta
from bandwidth.messaging.models.message_request import MessageRequest
messaging_client = bandwidth_client.messaging_client.client
body = MessageRequest()
body.application_id = "93de2206-9669-4e07-948d-329f4b722ee2"
body.to = ["+17777777777"]
body.mfrom = "+18888888888"
body.text = "Greetings!"
try:
response = messaging_client.create_message(account_id, body)
print(response.body.id)
print(response.status_code)
except APIException as e:
print(e.description)
print(e.response_code)
from bandwidth.api import messages_api
from bandwidth.model.messaging_request_error import MessagingRequestError
from bandwidth.model.create_message_request_error import CreateMessageRequestError
from bandwidth.model.message_request import MessageRequest
from bandwidth.model.message import Message
messaging_api_instance = messages_api.MessagesApi(api_client)
message_request = MessageRequest(
application_id="93de2206-9669-4e07-948d-329f4b722ee2",
to=["+17777777777"],
_from="+18888888888",
text="Greetings!"
)
try:
api_response = messaging_api_instance.create_message(account_id, message_request)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->create_message: %s\n" % e)
List Messages
- v14
- v15-beta
messaging_client = bandwidth_client.messaging_client.client
message_id = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6"
try:
response = messaging_client.get_messages(account_id, message_id=message_id)
print(response.body.total_count)
except APIException as e:
print(e.response_code)
from bandwidth.api import messages_api
messaging_api_instance = messages_api.MessagesApi(api_client)
message_id = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6"
try:
api_response = messaging_api_instance.list_messages(account_id, message_id=message_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MessagesApi->list_messages: %s\n" % e)
Media
List Media
- v14
- v15-beta
BW_ACCOUNT_ID = "12345"
try:
response = messaging_client.list_media(BW_ACCOUNT_ID)
print(response.body)
except APIException as e:
print(e.response_code)
api_instance = media_api.MediaApi(api_client)
account_id = "9900000" # str | Your Bandwidth Account ID.
continuation_token = "1XEi2tsFtLo1JbtLwETnM1ZJ+PqAa8w6ENvC5QKvwyrCDYII663Gy5M4s40owR1tjkuWUif6qbWvFtQJR5/ipqbUnfAqL254LKNlPy6tATCzioKSuHuOqgzloDkSwRtX0LtcL2otHS69hK343m+SjdL+vlj71tT39" # str | Continuation token used to retrieve subsequent media. (optional)
# example passing only required values which don't have defaults set
try:
api_response = api_instance.list_media(account_id)
pprint(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->list_media: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.list_media(account_id, continuation_token=continuation_token)
pprint(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->list_media: %s\n" % e)
Get Media
- v14
- v15-beta
BW_ACCOUNT_ID = "12345"
media_file_name = 'media-id-123'
try:
response = messaging_client.get_media(BW_ACCOUNT_ID, media_file_name)
downloaded_media_file = response.body
except APIException as e:
print(e.response_code)
api_instance = media_api.MediaApi(api_client)
account_id = "9900000" # str | Your Bandwidth Account ID.
media_id = "14762070468292kw2fuqty55yp2b2/0/bw.png" # str | Media ID to retrieve.
try:
api_response = api_instance.get_media(account_id, media_id)
pprint(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->get_media: %s\n" % e)
Upload Media
- v14
- v15-beta
BW_ACCOUNT_ID = "12345"
media_file_name = 'sample_file_name'
media_file = b'12345' #Any binary string will work for the upload. This includes file contents
try:
messaging_client.upload_media(BW_ACCOUNT_ID, media_file_name, media_file)
except APIException as e:
print(e.response_code)
api_instance = media_api.MediaApi(api_client)
account_id = "9900000" # str | Your Bandwidth Account ID.
media_id = "14762070468292kw2fuqty55yp2b2/0/bw.png" # str | Media ID to retrieve.
body = open('/path/to/file', 'rb') # file_type |
content_type = "audio/wav" # str | The media type of the entity-body. (optional)
cache_control = "no-cache" # str | General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. (optional)
# example passing only required values which don't have defaults set
try:
api_instance.upload_media(account_id, media_id, body)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->upload_media: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
api_instance.upload_media(account_id, media_id, body, content_type=content_type, cache_control=cache_control)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->upload_media: %s\n" % e)
Delete Media
- v14
- v15-beta
BW_ACCOUNT_ID = "12345"
media_id = "m-1234"
try:
messaging_client.delete_media(BW_ACCOUNT_ID, media_id)
except APIException as e:
print(e.response_code)
api_instance = media_api.MediaApi(api_client)
account_id = "9900000" # str | Your Bandwidth Account ID.
media_id = "14762070468292kw2fuqty55yp2b2/0/bw.png" # str | Media ID to retrieve.
try:
api_instance.delete_media(account_id, media_id)
except bandwidth.ApiException as e:
print("Exception when calling MediaApi->delete_media: %s\n" % e)
BXML
Imports
- v14
- v15-beta
from bandwidth.voice.bxml.response import Response # <Response />
from bandwidth.voice.bxml.bxml import Bxml # <Bxml />
from bandwidth.voice.bxml.verbs import *
from bandwidth.voice.bxml.verbs import SpeakSentence
from bandwidth.model.bxml.response import Response # <Response />
from bandwidth.model.bxml.bxml import Bxml # <Bxml />
from bandwidth.model.bxml.verbs import *
from bandwidth.model.bxml.verbs import SpeakSentence
Bridge
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Bridge
bridge = Bridge(
call_id="c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d"
)
from bandwidth.model.bxml.verbs import Bridge
bridge = Bridge(
target_call="c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d"
)
Conference
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Conference
conference = Conference(
conference_name="my-conference-name"
)
from bandwidth.model.bxml.verbs import Conference, PlayAudio
play_audio = PlayAudio(
url="https://audio.url/audio1.wav"
)
conference = Conference(
name="my-conference-name",
audio_and_recording_verbs=[play_audio]
)
Forward
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Forward
forward = Forward(
to="+10987654321",
from_="+11234567890"
)
from bandwidth.model.bxml.verbs import Forward
forward = Forward(
to="+10987654321",
_from="+11234567890"
)
Gather
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Gather
gather = Gather(
gather_url="https://gather.url/nextBXML"
nested_verbs=[other_verbs] # For nested audio producers (speak sentence/play audio)
)
from bandwidth.model.bxml.verbs import Gather
gather = Gather(
audio_verbs=[other_verbs], # For nested audio producers (speak sentence/play audio)
gather_url="https://gather.url/nextBXML"
)
# or
gather.add_verb(other_verbs) # For nested audio producers (speak sentence/play audio)
Hangup
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Hangup
hangup = Hangup()
from bandwidth.model.bxml.verbs import Hangup
hangup = Hangup()
Pause
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Pause
pause = Pause(duration=2)
from bandwidth.model.bxml.verbs import Pause
pause = Pause(duration=2)
Pause Recording
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import PauseRecording
pause_recording = PauseRecording()
from bandwidth.model.bxml.verbs import PauseRecording
pause_recording = PauseRecording()
Play Audio
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import PlayAudio
play_audio = PlayAudio(
url="https://audio.url/audio1.wav"
)
from bandwidth.model.bxml.verbs import Play Audio
play_audio = PlayAudio(
audio_uri="https://audio.url/audio1.wav"
)
Record
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Record
record = Record(
record_complete_url="https://myapp.com/nextBXML",
recording_available_url="https://myapp.com/recordingAvailable",
max_duration=10
)
from bandwidth.model.bxml.verbs import Record
record = Record(
record_complete_url="https://myapp.com/nextBXML",
recording_available_url="https://myapp.com/recordingAvailable",
max_duration=10
)
Redirect
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Redirect
redirect = Redirect(
redirect_url="http://flow.url/newFlow"
)
from bandwidth.model.bxml.verbs import Redirect
redirect = Redirect(
redirect_url="http://flow.url/newFlow"
)
Resume Recording
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import ResumeRecording
resume_recording = ResumeRecording()
from bandwidth.model.bxml.verbs import ResumeRecording
resume_recording = ResumeRecording()
Ring
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Ring
ring = Ring(
duration=10,
answer_call=False
)
from bandwidth.model.bxml.verbs import Ring
ring = Ring(
duration=10,
answer_call=False
)
Send DTMF
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import SendDtmf
send_dtmf = SendDtmf(dtmf="12w34")
from bandwidth.model.bxml.verbs import SendDtmf
send_dtmf = SendDtmf(digits="12w34")
Speak Sentence
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import SpeakSentence
speak_sentence = SpeakSentence(
sentence="This is a test.",
voice="julie"
)
from bandwidth.model.bxml.verbs import SpeakSentence
speak_sentence = SpeakSentence(
sentence="This is a test.",
voice="julie"
)
Start Gather
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StartGather
start_gather = StartGather(
dtmfUrl="https://startgather.url/callback"
)
from bandwidth.model.bxml.verbs import StartGather
start_gather = StartGather(
dtmf_url="https://startgather.url/callback"
)
Start Recording
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StartRecording
start_recording = StartRecording(
recording_available_url="https://myapp.com/noBXML"
)
from bandwidth.model.bxml.verbs import StartRecording
start_recording = StartRecording(
recording_available_url="https://myapp.com/noBXML"
)
Start Stream
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StartStream
from bandwidth.voice.bxml.verbs import StreamParam
stream_param = StreamParam(
name="internal_id",
value="call_ABC"
)
start_stream = StartStream(
name="live_audience",
tracks="both",
destination="wss://live-studio-audience.myapp.example.com",
stream_events_url="https://myapp.example.com/noBXML",
stream_params=[stream_param]
)
from bandwidth.model.bxml.verbs import StartStream
from bandwidth.model.bxml.verbs import StreamParam
stream_param = StreamParam(
name="internal_id",
value="call_ABC"
)
start_stream = StartStream(
name="live_audience",
tracks="both",
destination="wss://live-studio-audience.myapp.example.com",
stream_events_url="https://myapp.example.com/noBXML",
stream_params=[stream_param]
)
Stop Gather
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StopGather
stop_gather = StopGather()
from bandwidth.model.bxml.verbs import StopGather
stop_gather = StopGather()
Stop Recording
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StopRecording
stop_recording = StopRecording()
from bandwidth.model.bxml.verbs import StopRecording
stop_recording = StopRecording()
Stop Stream
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import StopStream
stop_stream = StopStream(
name="live_audience",
)
from bandwidth.model.bxml.verbs import StopStream
stop_stream = StopStream(
name="live_audience",
)
Tag
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Tag
tag = Tag(
tag="audio playing"
)
from bandwidth.model.bxml.verbs import Tag
tag = Tag(
tag="audio playing"
)
Transfer
- v14
- v15-beta
from bandwidth.voice.bxml.verbs import Transfer, PhoneNumber, SipUri
phone_number = PhoneNumber(
number="+11234567892"
)
sip_uri = SipUri(
uri="sip:user@server.com"
)
transfer = Transfer(
transfer_caller_id="+11234567891",
phone_numbers=[phone_number]
)
from bandwidth.voice.bxml.verbs import Transfer, PhoneNumber, SipUri
phone_number = PhoneNumber(
number="+11234567892"
)
sip_uri = SipUri(
uri="sip:user@server.com"
)
transfer = Transfer(
transfer_caller_id="+11234567891",
transfer_to=[phone_number, sip_uri]
)
Calls
Create Call
- v14
- v15-beta
from bandwidth.voice.models.create_call_request import CreateCallRequest
bandwidth_client = BandwidthClient(
voice_basic_auth_user_name=BW_USERNAME,
voice_basic_auth_password=BW_PASSWORD
)
voice_client = bandwidth_client.voice_client.client
body = CreateCallRequest()
body.application_id = BW_VOICE_APPLICATION_ID
body.to = "+19195551234"
body.mfrom = "+19195554321"
body.answer_url = "https://www.myCallbackServer.com/webhooks/answer"
try:
response = voice_client.create_call(account_id, body)
print(response.body.call_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import calls_api
calls_api_instance = calls_api.CallsApi(api_client)
create_call = CreateCall(
to="+19195551234",
_from="+19195554321",
application_id="1234-qwer-5679-tyui",
answer_url="https://www.myCallbackServer.com/webhooks/answer",
)
try:
api_response = calls_api_instance.create_call(account_id, create_call)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling CallsApi->create_call: %s\n" % e)
Get Call Information
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
result = voice_client.get_call(account_id, call_id)
print(result.body.state)
except APIException as e:
print(e.response_code)
from bandwidth.api import calls_api
calls_api_instance = calls_api.CallsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = calls_api_instance.get_call_state(account_id, call_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling CallsApi->get_call_state: %s\n" % e)
Update Call
- v14
- v15-beta
from bandwidth.voice.models.modify_call_request import ModifyCallRequest
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
body = ModifyCallRequest()
body.redirect_url = "https://myServer.com/bandwidth/webhooks/redirect"
body.state = "active"
try:
voice_client.modify_call(account_id, call_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import calls_api
from bandwidth.model.update_call import UpdateCall
from bandwidth.model.call_state_enum import CallStateEnum
calls_api_instance = calls_api.CallsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
update_call = UpdateCall(
state=CallStateEnum("active"),
redirect_url="https://myServer.com/bandwidth/webhooks/redirect",
)
try:
calls_api_instance.update_call(account_id, call_id, update_call)
except bandwidth.ApiException as e:
print("Exception when calling CallsApi->update_call: %s\n" % e)
Replace Call BXML
- v14
- v15-beta
from bandwidth.voice.bxml.bxml import Bxml
from bandwidth.voice.bxml.verbs import *
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
bxml = Bxml()
speak_sentence = SpeakSentence(
sentence="This is a test.",
voice="julie"
)
bxml.add_verb(speak_sentence)
try:
voice_client.modify_call_bxml(account_id, call_id, bxml.to_bxml())
except APIException as e:
print(e.response_code)
from bandwidth.api import calls_api
from bandwidth.model.bxml.bxml import Bxml
from bandwidth.model.bxml.verbs import SpeakSentence
calls_api_instance = calls_api.CallsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
bxml = Bxml()
speak_sentence = SpeakSentence(
text='This is a test.',
voice="julie"
)
bxml.add_verb(speak_sentence)
try:
calls_api_instance.update_call_bxml(account_id, call_id, bxml.to_bxml())
except bandwidth.ApiException as e:
print("Exception when calling CallsApi->update_call_bxml: %s\n" % e)
Conferences
List Conferences
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
try:
response = voice_client.get_conferences(account_id)
if len(response.body) > 0:
print(response.body[0].id)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
try:
api_response = conferences_api_instance.list_conferences(account_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->list_conferences: %s\n" % e)
Get Conference Information
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
try:
response = voice_client.get_conference(account_id, conference_id)
print(response.body.name)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
try:
api_response = conferences_api_instance.get_conference(account_id, conference_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->get_conference: %s\n" % e)
Update Conference
- v14
- v15-beta
from bandwidth.voice.models.modify_conference_request import ModifyConferenceRequest
from bandwidth.voice.models.status_enum import StatusEnum
voice_client = bandwidth_client.voice_client.client
body = ModifyConferenceRequest()
body.status = StatusEnum.ACTIVE
body.redirect_url = "https://myServer.com/bandwidth/webhooks/conferenceRedirect"
conference_id = "conf-1234"
try:
voice_client.modify_conference(account_id, conference_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
from bandwidth.model.update_conference import UpdateConference
from bandwidth.model.conference_state_enum import ConferenceStateEnum
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
update_conference = UpdateConference(
status=ConferenceStateEnum("active"),
redirect_url="https://myServer.com/bandwidth/webhooks/conferenceRedirect"
)
try:
conferences_api_instance.update_conference(account_id, conference_id, update_conference)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->update_conference: %s\n" % e)
Update Conference BXML
- v14
- v15-beta
N/A - Not implemented
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
bxml = Bxml()
speak_sentence = SpeakSentence(
text='This is a test.',
voice="julie"
)
bxml.add_verb(speak_sentence)
try:
conferences_api_instance.update_conference_bxml(account_id, conference_id, bxml.to_bxml())
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->update_conference_bxml: %s\n" % e)
Get Conference Member
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
member_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_conference_member(account_id, conference_id, member_id)
print(response.body.member_url)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
member_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = conferences_api_instance.get_conference_member(account_id, conference_id, member_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->get_conference_member: %s\n" % e)
Update Conference Member
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-1234"
call_id = "c-1234"
body = ConferenceMemberState()
body.mute = True
try:
voice_client.modify_conference_member(account_id, conference_id, call_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
from bandwidth.model.update_conference_member import UpdateConferenceMember
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
member_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
update_conference_member = UpdateConferenceMember(
mute=False,
hold=False,
call_ids_to_coach=["c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"],
)
try:
conferences_api_instance.update_conference_member(account_id, conference_id, member_id, update_conference_member)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->update_conference_member: %s\n" % e)
List Conference Recordings
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
try:
response = voice_client.get_conference_recordings(account_id, conference_id)
if len(response.body) > 0:
print(response.body[0].name)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
try:
api_response = conferences_api_instance.list_conference_recordings(account_id, conference_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->list_conference_recordings: %s\n" % e)
Get Conference Recording Information
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_conference_recording(account_id, conference_id, recording_id)
print(response.body.application_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = conferences_api_instance.get_conference_recording(account_id, conference_id, recording_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->get_conference_recording: %s\n" % e)
Download Conference Recording
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_download_conference_recording(account_id, conference_id, recording_id)
downloaded_recording = response.body
except APIException as e:
print(e.response_code)
from bandwidth.api import conferences_api
conferences_api_instance = conferences_api.ConferencesApi(api_client)
conference_id = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = conferences_api_instance.download_conference_recording(account_id, conference_id, recording_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling ConferencesApi->download_conference_recording: %s\n" % e)
Recordings
List Account Call Recordings
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
try:
result = voice_client.get_query_call_recordings(account_id)
if len(result.body) > 0:
print(result.body[0].recording_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
try:
api_response = recordings_api_instance.list_account_call_recordings(account_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->list_account_call_recordings: %s\n" % e)
Update Recording
- v14
- v15-beta
from bandwidth.voice.models.modify_call_recording_request import ModifyCallRecordingRequest
voice_client = bandwidth_client.voice_client.client
body = ModifyCallRecordingRequest()
body.state = "paused"
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
voice_client.modify_call_recording_state(account_id, call_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
from bandwidth.model.update_call_recording import UpdateCallRecording
from bandwidth.model.recording_state_enum import RecordingStateEnum
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
update_call_recording = UpdateCallRecording(
state=RecordingStateEnum("paused"),
)
try:
recordings_api_instance.update_call_recording_state(account_id, call_id, update_call_recording)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->update_call_recording_state: %s\n" % e)
List Call Recordings
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_call_recordings(account_id, call_id)
if len(response.body) > 0:
print(response.body[0].recording_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = recordings_api_instance.list_call_recordings(account_id, call_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->list_call_recordings: %s\n" % e)
Get Call Recording
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_call_recording(account_id, call_id, recording_id)
print(response.body.application_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = recordings_api_instance.get_call_recording(account_id, call_id, recording_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->get_call_recording: %s\n" % e)
Delete Recording
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
voice_client.delete_recording(account_id, call_id, recording_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
recordings_api_instance.delete_recording(account_id, call_id, recording_id)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->delete_recording: %s\n" % e)
Download Recording
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_download_call_recording(account_id, call_id, recording_id)
downloaded_recording = response.body
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = recordings_api_instance.download_call_recording(account_id, call_id, recording_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->download_call_recording: %s\n" % e)
Delete Recording Media
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
voice_client.delete_recording_media(account_id, call_id, recording_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
recordings_api_instance.delete_recording_media(account_id, call_id, recording_id)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->delete_recording_media: %s\n" % e)
Get Transcription
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
response = voice_client.get_call_transcription(account_id, call_id, recording_id)
print(response.body.transcripts)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
api_response = recordings_api_instance.get_call_transcription(account_id, call_id, recording_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->get_call_transcription: %s\n" % e)
Create Transcription Request
- v14
- v15-beta
from bandwidth.voice.models.transcribe_recording_request import TranscribeRecordingRequest
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
body = TranscribeRecordingRequest()
body.callback_url = "https://myServer.com/bandwidth/webhooks/transcriptionAvailable"
try:
voice_client.create_transcribe_call_recording(account_id, call_id, recording_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
from bandwidth.model.transcribe_recording import TranscribeRecording
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
transcribe_recording = TranscribeRecording(
callback_url="https://myServer.com/bandwidth/webhooks/transcriptionAvailable"
)
try:
recordings_api_instance.transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->transcribe_call_recording: %s\n" % e)
Delete Transcription
- v14
- v15-beta
voice_client = bandwidth_client.voice_client.client
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
voice_client.delete_call_transcription(account_id, call_id, recording_id)
except APIException as e:
print(e.response_code)
from bandwidth.api import recordings_api
recordings_api_instance = recordings_api.RecordingsApi(api_client)
call_id = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
recording_id = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"
try:
recordings_api_instance.delete_call_transcription(account_id, call_id, recording_id)
except bandwidth.ApiException as e:
print("Exception when calling RecordingsApi->delete_call_transcription: %s\n" % e)
Telephone Number Lookup
Create Lookup
- v14
- v15-beta
from bandwidth.phonenumberlookup.models.order_request import OrderRequest
phone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client
body = OrderRequest()
body.tns = ["+15554443333"]
try:
response = phone_number_lookup_client.create_lookup_request(account_id, body)
print(response.body.request_id)
except APIException as e:
print(e.response_code)
from bandwidth.model.lookup_request import LookupRequest
phone_number_lookup_api_instance = phone_number_lookup_api.PhoneNumberLookupApi(api_client)
lookup_request = LookupRequest(
tns=["+15554443333"],
)
try:
api_response = phone_number_lookup_api_instance.create_lookup(account_id, lookup_request)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling PhoneNumberLookupApi->create_lookup: %s\n" % e)
Get Lookup Request Status
- v14
- v15-beta
phone_number_lookup_client = bandwidth_client.phone_number_lookup_client.client
request_id = "004223a0-8b17-41b1-bf81-20732adf5590"
try:
response = phone_number_lookup_client.get_lookup_request_status(account_id, request_id)
print(response.body.status)
except APIException as e:
print(e.response_code)
phone_number_lookup_api_instance = phone_number_lookup_api.PhoneNumberLookupApi(api_client)
request_id = "004223a0-8b17-41b1-bf81-20732adf5590"
try:
api_response = phone_number_lookup_api_instance.get_lookup_status(account_id, request_id)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling PhoneNumberLookupApi->get_lookup_status: %s\n" % e)
Multi-Factor Authentication
Voice MFA Code
- v14
- v15-beta
from bandwidth.multifactorauth.models.two_factor_code_request_schema import TwoFactorCodeRequestSchema
mfa_client = bandwidth_client.multi_factor_auth_client.mfa
body = TwoFactorCodeRequestSchema(
mfrom = "+15554443333",
to = "+15553334444",
application_id = "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
scope = "2FA",
digits = 6,
message = "Your temporary {NAME} {SCOPE} code is {CODE}"
)
try:
auth_client.create_voice_two_factor(account_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import mfa_api
from bandwidth.model.code_request import CodeRequest
mfa_api_instance = mfa_api.MFAApi(api_client)
code_request = CodeRequest(
to="+15553334444",
_from="+15554443333",
application_id="66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
scope="2FA",
message="Your temporary {NAME} {SCOPE} code is {CODE}",
digits=6,
)
try:
api_response = mfa_api_instance.generate_voice_code(account_id, code_request)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MFAApi->generate_messaging_code: %s\n" % e)
Messaging MFA Code
- v14
- v15-beta
from bandwidth.multifactorauth.models.two_factor_code_request_schema import TwoFactorCodeRequestSchema
mfa_client = bandwidth_client.multi_factor_auth_client.mfa
body = TwoFactorCodeRequestSchema(
mfrom = "+15554443333",
to = "+15553334444",
application_id = "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
scope = "2FA",
digits = 6,
message = "Your temporary {NAME} {SCOPE} code is {CODE}"
)
try:
auth_client.create_messaging_two_factor(account_id, body)
except APIException as e:
print(e.response_code)
from bandwidth.api import mfa_api
from bandwidth.model.code_request import CodeRequest
mfa_api_instance = mfa_api.MFAApi(api_client)
code_request = CodeRequest(
to="+15553334444",
_from="+15554443333",
application_id="66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
scope="2FA",
message="Your temporary {NAME} {SCOPE} code is {CODE}",
digits=6,
)
try:
api_response = mfa_api_instance.generate_messaging_code(account_id, code_request)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MFAApi->generate_messaging_code: %s\n" % e)
Verify MFA Code
- v14
- v15-beta
from bandwidth.multifactorauth.models.two_factor_verify_request_schema import TwoFactorVerifyRequestSchema
auth_client = bandwidth_client.multi_factor_auth_client.mfa
body = TwoFactorVerifyRequestSchema(
to = USER_NUMBER,
application_id = "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
scope = "2FA",
code = "123456", #This is the user's input to validate
expiration_time_in_minutes = 3
)
try:
response = auth_client.create_verify_two_factor(account_id, body)
print(response.body.valid)
except APIException as e:
print(e.response_code)
from bandwidth.api import mfa_api
from bandwidth.model.code_request import CodeRequest
mfa_api_instance = mfa_api.MFAApi(api_client)
verify_code_request = VerifyCodeRequest(
to="+19195551234",
scope="2FA",
expiration_time_in_minutes=3,
code="123456",
)
try:
api_response = mfa_api_instance.verify_code(account_id, verify_code_request)
print(api_response)
except bandwidth.ApiException as e:
print("Exception when calling MFAApi->verify_code: %s\n" % e)