voxjar#

class voxjar.Client(url=None, token=None, timeout=None)[source]#

Bases: object

Voxjar API client.

Parameters:
  • url (str, optional) – The URL for the API.
  • token (str, optional) – The JWT authenticating this Client to the API.
  • timeout (int, optional) – The timeout for API calls.
push(metadata, audio)[source]#

Enqueue a call to be processed by Voxjar.

Parameters:
  • metadata (dict) – The metadata for the call.
  • audio (file) – The raw audio bytes of the call.
Returns:

The metadata for the uploaded call.

Return type:

metadata (dict)

Example

import datetime
import voxjar

metadata = {
    'identifier': 'callIdentifier',
    'type': {
        'identifier': 'typeIdentifier',
        'name': 'typeName',
    },
    'timestamp': datetime.datetime.now(),
    'direction': 'OUTGOING',  # or INCOMING
    'agents': [{
        'identifier': 'agentIdentifier',
        'name': 'Agent Name',
        'phoneNumber': 1234567890,
        # optional
        'hiredAt': '2018-05-29T05:14:18+00:00',
        # optional
        'metadata': {
            'someCustomField': 'someCustomValue',
        },
    }],
    'customers': [{
        'identifier': 'customerIdentifier',
        'name': 'Customer Name',
        'phoneNumber': 9876543210,
        # optional
        'metadata': {
            'someCustomField': 'someCustomValue',
        },
    }],
    # optional
    'disposition': {
        'identifier': 'dispositionIdentifier',
        'name': 'dispositionName',
    },
    # optional
    'tags': ['tag1', 'tag2'],
    # optional
    'metadata': {
        'someCustomField': 'someCustomValue',
    },
}

client = voxjar.Client()

with open('test.wav', 'rb') as f:
    client.push(metadata, f)
push_request(metadata, audio=None)[source]#

A file-like object used to enqueue a call audio file to be processed by Voxjar.

Parameters:
  • metadata (dict) – The metadata for the call.
  • audio (file) – The raw audio bytes of the call.
Returns:

The metadata for the uploaded call.

Return type:

metadata (dict)

Example

import datetime
import requests
import voxjar

metadata = {
    'identifier': 'callIdentifier',
    'type': {
        'identifier': 'typeIdentifier',
        'name': 'typeName',
    },
    'timestamp': datetime.datetime.now(),
    'direction': 'OUTGOING',  # or INCOMING
    'agents': [{
        'identifier': 'agentIdentifier',
        'name': 'Agent Name',
        'phoneNumber': 1234567890,
        # optional
        'hiredAt': '2018-05-29T05:14:18+00:00',
        # optional
        'metadata': {
            'someCustomField': 'someCustomValue',
        },
    }],
    'customers': [{
        'identifier': 'customerIdentifier',
        'name': 'Customer Name',
        'phoneNumber': 9876543210,
        # optional
        'metadata': {
            'someCustomField': 'someCustomValue',
        },
    }],
    # optional
    'disposition': {
        'identifier': 'dispositionIdentifier',
        'name': 'dispositionName',
    },
    # optional
    'tags': ['tag1', 'tag2'],
    # optional
    'metadata': {
        'someCustomField': 'someCustomValue',
    },
}

client = voxjar.Client()

r = requests.get('https://somesource.com', stream=True)
with client.push_request(metadata) as push_request:
    for chunk in r.iter_content(chunk_size=1024):
        push_request.write(chunk)
    push_request.push()