A Simple SDK for Joker's Voice API.
Project description
Joker API SDK
JokerSDK
is an asynchronous python library to wrap around the JokerAPI Voice API.
Features
- Basic Number class integration to properly format the Numbers.
- Dial class to dial a phone number quickly.
Requirements
- Python >= 3.10
- *httpx
Install JokerSDK
JokerSDK via PyPi:
$ pip install JokerSDK
Or, if you wish to download it directly from this repository:
$ python setup.py install
Initiation
from JokerAPI import JokerMethod
# Joker Initiatior
JokerInstance = JokerMethod()
# Set API Key
JokerInstance.api_key = "API_KEY"
Initiate the SDK Class and set a api key, this may also be done by:
JokerInstance = JokerMethod(api_key="API_KEY")
Simple Outbound Call
from JokerAPI import JokerMethod, Number
# Joker Initiatior
JokerInstance = JokerMethod()
# Set API Key
JokerInstance.api_key = "API_KEY"
# Dial '+111111111' from '+111111111'.
sid: str | None = JokerInstance.dial(dial_to = Number("+111111111"), dial_from = Number("111111111"))
Run the function dial
, a part of the JokerInstance
object.
Simple Outbound Call & Playing Audio
from JokerAPI import JokerMethod, Number
# Joker Initiatior
JokerInstance = JokerMethod()
# Set API Key
JokerInstance.api_key = "API_KEY"
# Dial '+111111111' from '+111111111'.
call_sid: str | None = JokerInstance.dial(dial_to = Number("+111111111"), dial_from = Number("111111111"))
# Play audio into the live channel
JokerInstance.play(call_sid, "https://my.callbackserver.xyz/audio.wav")
Run the function dial
to create an outbound call, and then use the SID to play audio into it.
Class Integration
import JokerAPI
class JokerClass(JokerAPI.JokerMethod):
def __init__(self, **kwargs) -> None:
super().__init__(kwargs)
def set_key(self, key) -> None:
self.api_key = key
def create_outbound_call(self, *args, **kwargs) -> asyncio.run:
return self.dial(args, kwargs)
Integrate the JokerMethod
class a part of the JokerAPI
library and use it in a custom class.
Callback server example
import flask
from typing import Any
app: flask.Flask = flask.Flask(__name__)
@app.route("/your_project/callback", methods=["POST"])
async def callbacks() -> Any[flask.Response, flask.jsonify, str]:
status: dict[str] = {flask.request.json['callsid']: flask.request.json['status']}
print(f"The CallSID ({flask.request.json['callsid']}) is {flask.request.json['status'].split('.')[1]}")
return "Any Response."
app.run("0.0.0.0", port=8080)
# Example output for when callback 'call.ringing' is sent.
#> The CallSID ('e074a38cc9a4e77ec') is ringing
Create a flask web app to recieve and read callback webhooks from JokerAPI proxy nodes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
JokerSDK-0.0.38.tar.gz
(20.1 kB
view hashes)
Built Distribution
JokerSDK-0.0.38-py3-none-any.whl
(20.1 kB
view hashes)
Close
Hashes for JokerSDK-0.0.38-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42204cd9b1b57532cfbda46d017bd58f35350345e8ba8e5e2285ca245bad4b80 |
|
MD5 | 386c1f6f6480ed35f28b01037ddd10b8 |
|
BLAKE2b-256 | 51daa6101ffc48461a26cee1ffb10b1869e3f6a7685a704aad388b0da5ea58b2 |