Skip to main content

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

import JokerAPI

# Joker Initiatior
JokerInstance: JokerAPI.SDK = JokerAPI.SDK()
# Set API Key
JokerInstance.api_key = "API_KEY"

Asynchronous Outbound Call

import asyncio, JokerAPI

# Joker Initiatior
JokerInstance: JokerAPI.SDK = JokerAPI.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="111111111", dial_from="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


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.34.tar.gz (18.2 kB view hashes)

Uploaded Source

Built Distribution

JokerSDK-0.0.34-py3-none-any.whl (18.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page