A Simple asyncronous SDK for Joker's Voice API.
Project description
Joker API SDK
JokerSDK is an asynchronous python library to wrap around the JokerAPI.co voice API.
Install JokerSDK
pip install JokerSDK
Initiation
from JokerAPI import SDK, Number
# Joker Initiatior
JokerInstance: SDK = SDK()
# Set API Key
JokerInstance.api_key = "API_KEY"
Asynchronous Outbound Call
import asyncio
from JokerAPI import SDK, Number
# Joker Initiatior
JokerInstance: SDK = SDK()
# Set API Key
JokerInstance.api_key = "API_KEY"
# Run the asynchronous function and dial US('111111111') from US('+111111111')
asyncio.run( JokerInstance.dial(dial_to=Number("+111111111"), dial_from=Number("111111111")) )
Class Integration
import asyncio, JokerAPI
class JokerClass(JokerAPI.SDK):
def __init__(self, **kwargs) -> None:
super().__init__(kwargs)
def set_key(self, key) -> None:
self.api_key = key
def dial(self, *args, **kwargs) -> asyncio.run:
return asyncio.run(self.dial(args, kwargs))
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
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.36.tar.gz
(18.6 kB
view hashes)
Built Distribution
JokerSDK-0.0.36-py3-none-any.whl
(19.0 kB
view hashes)
Close
Hashes for JokerSDK-0.0.36-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590fa5189ddc7169f574a8288b93b25e8135ea0428a7f3c30effb89d1d5fef2a |
|
MD5 | 713f89e2a36f944466d00a574d65ca3b |
|
BLAKE2b-256 | 1fb09c82645364b9c1c04224ed36fa41626d56e31b77854dc8a29d8b22836c96 |