Skip to main content

Voximplant API client library

Project description

Prerequisites

In order to use the Voximplant Python SDK, you need the following:

  1. A developer account. If you don’t have one, sign up here.

  2. A private API key. There are 2 options to obtain it:

    1. Either generate it in the Voximplant Control panel

    2. Or call the CreateKey HTTP API method with the specified authentication parameters. You’ll receive a response with the result field in it. Save the result value in a file (since we don’t store the keys, save it securely on your side).

  3. Python 2.x or 3.x runtime with pip and setuptools>=18.5 installed

How to use

Go to your project folder and install the SDK using pip:

python -m pip install --user voximplant-apiclient

Then import the SDK in your script

from voximplant.apiclient import VoximplantAPIConfig, VoximplantAPI

Next, specify the path to the JSON service account file either in the constructor or using the environment.

constructor:

config = VoximplantAPIConfig(
    credentials_file_path="/path/to/credentials.json",
)
api = VoximplantAPI(config=config)

env:

export VOXIMPLANT_CREDENTIALS=/path/to/credentials.json

Examples

Start a scenario

from voximplant.apiclient import VoximplantAPIConfig, VoximplantAPI, VoximplantException

if __name__ == "__main__":
    config = VoximplantAPIConfig(
        credentials_file_path="credentials.json",
    )
    api = VoximplantAPI(config=config)

    # Start a scenario of the user 1

    RULE_ID = 1
    SCRIPT_CUSTOM_DATA = "mystr"
    USER_ID = 1

    try:
        res = api.start_scenarios(RULE_ID, script_custom_data=SCRIPT_CUSTOM_DATA, user_id=USER_ID)
        print(res)
    except VoximplantException as e:
        print("Error: {}".format(e.message))

Send an SMS

from voximplant.apiclient import VoximplantAPIConfig, VoximplantAPI, VoximplantException

if __name__ == "__main__":
    config = VoximplantAPIConfig(
        credentials_file_path="credentials.json",
    )
    api = VoximplantAPI(config=config)

    # Send the SMS with the "Test message" text from the phone number 447443332211 to the phone number 447443332212

    SOURCE = "447443332211"
    DESTINATION = "447443332212"
    SMS_BODY = "Test message"

    try:
        res = api.send_sms_message(SOURCE, DESTINATION, SMS_BODY)
        print(res)
    except VoximplantException as e:
        print("Error: {}".format(e.message))

Get a call history item

from voximplant.apiclient import VoximplantAPIConfig, VoximplantAPI, VoximplantException
import pytz
import datetime

if __name__ == "__main__":
    config = VoximplantAPIConfig(
        credentials_file_path="credentials.json",
    )
    api = VoximplantAPI(config=config)

    # Get the first call session history record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTC

    FROM_DATE = datetime.datetime(2012, 1, 1, 0, 0, 0, pytz.utc)
    TO_DATE = datetime.datetime(2014, 1, 1, 0, 0, 0, pytz.utc)
    COUNT = 1

    try:
        res = api.get_call_history(FROM_DATE, TO_DATE, count=COUNT)
        print(res)
    except VoximplantException as e:
        print("Error: {}".format(e.message))

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

voximplant_apiclient-2.7.0.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voximplant_apiclient-2.7.0-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file voximplant_apiclient-2.7.0.tar.gz.

File metadata

  • Download URL: voximplant_apiclient-2.7.0.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for voximplant_apiclient-2.7.0.tar.gz
Algorithm Hash digest
SHA256 5baa3d065f0e7cfab89168e7fa5a687555b4ea06471e8fcc097910caa65e653e
MD5 7a6db6e3b161baaa5085bfa9508897f5
BLAKE2b-256 923a3e4e0616247311719b0cdac19c47f2d2ba28bcbc685ef9c83cbb6ec94aae

See more details on using hashes here.

File details

Details for the file voximplant_apiclient-2.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for voximplant_apiclient-2.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7939e1cca2e617637c4680a877bcfe1b8b99bbead1efb05dd87425087bbb8aff
MD5 743114277fe70a4f907f539ba0037ce9
BLAKE2b-256 79b204228d07d77cf1aeff75e5bec25b90c702c7bfb3c03ef641b961addb0c98

See more details on using hashes here.

Supported by

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