Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apidaze/sdk-python
https://github.com/apidaze/sdk-python
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/apidaze/sdk-python
- Owner: apidaze
- Created: 2019-09-09T16:15:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T06:59:02.000Z (about 2 years ago)
- Last Synced: 2024-03-27T12:03:59.133Z (10 months ago)
- Language: Python
- Size: 143 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Python CI](https://github.com/apidaze/sdk-python/workflows/Python%20CI/badge.svg)
# Apidaze Python SDK
The Apidaze Python SDK contains the Python client of Apidaze REST API as well as an XML script builder.
The SDK allows you to leverage all Apidaze platform features such as making calls, sending text messages, serving IVR systems and many others in your Python based application.
The SDK also includes sample applications that demonstrate how to use the SDK interfaces.
See [Apidaze REST API specification](https://apidocs.voipinnovations.com) which includes XML Scripting Reference as well.# Requirements
- Python 3.4+
- lxml# Installation
To install the SDK just type
`make`
After that activate the virtual environment by typing
`source venv/bin/activate`
Now you're ready to install all python dependencies
`pip install -r requirements.txt`
You're now ready to use the SDK
# Quickstart
## SDK client
### Initiate the SDK Client
```python
from apidaze import Clientapidaze = Client(api_key=API_KEY, api_secret=API_SECRET)
```Where `API_KEY` and `API_SECRET` should be replaced with the real key and secret from your Apidaze application.
### Make a call
```python
apidaze.calls.place(
caller_id='9876543',
origin='123456',
destination='123456',
CallType.number)
```Where `caller_id` is the phone number to be presented as caller id, `origin` the phone number or SIP account to ring first, and `destination` is passed as a parameter to your External Script URL.
### Send a text message
```python
apidaze.messages.send(
origin='14125423968',
destination='14125423968',
body='Hello World from Python SDK'
)
```Where `origin` is the number to send the text from. Must be an active number on your account.
`destination` is the number you want to send the text to.
`body` is the message to send.### Download recordings
```python
response = apidaze.recordings.get(filename='my_recording.wav')
data = response['body']
file = open(filename, 'wb')
file.write(data)
file.close()
```In this example, we will download the recording named `my_recording.wav`.
## Script builder
The script builder is used to build XML instructions described in [XML Scripting Reference](https://apidocs.voipinnovations.com).
To build an instruction which echo back received audio to the caller with some delay use the following code.```python
from apidaze.script import Builder, Answer, Echo, Speakxmlbuilder = Builder()
answer = Answer()
speak = Speak(text='Thank you for trying our demo. Have an wonderful day!')
echo = Echo(500)xmlbuilder.add(answer).add(speak).add(echo)
xmlbuilder.printXML()
```The code above will produce the following XML
```xml
Thank you for trying our demo. Have an wonderful day!
500
```
## More examples
For more examples please see our [example repository](https://github.com/apidaze/sdk-python/tree/master/examples)