A Python module for communicating with the VocaFuse API and building voice-enabled applications.
Project description
VocaFuse Python SDK ✨
A comprehensive Python SDK for integrating with the VocaFuse voice API.
Installation
pip install -r requirements.txt
Quick Start
import os
from vocafuse import Client, AccessToken # Everything from main package
# Initialize client (auto-detects environment from API key prefix)
client = Client(
api_key=os.environ["VOCAFUSE_API_KEY"],
api_secret=os.environ["VOCAFUSE_API_SECRET"]
)
# List recordings
recordings = client.recordings.list(limit=10)
print(f"Found {len(recordings['data'])} recordings")
# Get specific recording
recording = client.recordings.get('recording_id')
print(f"Status: {recording['data']['status']}")
# Get transcription (nested access pattern)
transcription = client.recordings('recording_id').transcription.get()
print(f"Text: {transcription['data']['text']}")
# Generate JWT token for frontend authentication (standalone approach)
token = AccessToken(
api_key=os.environ["VOCAFUSE_API_KEY"],
api_secret=os.environ["VOCAFUSE_API_SECRET"],
identity='user_123'
)
jwt_response = token()
jwt_token = jwt_response['data']['jwt_token']
# Manage webhooks
webhook = client.webhooks.create(
url='https://myapp.com/webhooks',
events=['recording.completed', 'recording.failed']
)
# Verify webhook signatures (standalone validator from main package)
from vocafuse import RequestValidator
validator = RequestValidator('your-webhook-secret')
is_valid = validator.validate(webhook_payload, webhook_signature)
Features
🎯 Complete API Client
- Auto-environment Detection: Automatically detects dev/test/live from API key prefix
- Comprehensive Error Handling: Specific exceptions for different error types
- Type Hints: Full type hint support for better development experience
📡 Resource Management
- Recordings: List, get, delete recordings with transcription access
- Webhooks: Create, update, delete, list webhook configurations
- API Keys: Create, list, delete API keys for authentication
- Account: Get and update account information and settings
- JWT Generation: Standalone AccessToken class for frontend authentication
- Webhook Verification: Standalone RequestValidator for signature verification
🔐 JWT Token Generation
- Callable Interface: Simple
token()method for generation - Custom Scopes & Expiration: Flexible token configuration
API Reference
Main Client
Client(api_key, api_secret, base_url=None)
Initialize the VocaFuse client with API credentials.
from vocafuse import Client
client = Client(
api_key="your-api-key",
api_secret="your-api-secret"
)
Environment Auto-Detection:
sk_live_*→ Production:https://api.vocafuse.com/v1sk_test_*→ Testing:https://test-api.vocafuse.com/v1- Other → Development: Current dev URL
JWT Token Generation
AccessToken(api_key, api_secret, identity, base_url=None)
Generate JWT tokens for frontend authentication.
from vocafuse.jwt.access_token import AccessToken
# Create token generator
token = AccessToken(
api_key='your-api-key',
api_secret='your-api-secret',
identity='user_123'
)
# Generate token with default settings
response = token()
jwt_token = response['data']['jwt_token']
# Generate token with custom options
response = token(
expires_in=3600, # 1 hour
scopes=['recordings:read', 'recordings:write']
)
Default Scopes: ['voice-api.upload_recording']
Recordings Resource
# List recordings with filters
recordings = client.recordings.list(
page=0,
limit=50,
status='completed',
date_from='2024-01-01',
date_to='2024-12-31'
)
# Get specific recording
recording = client.recordings.get('recording_id')
# Delete recording
client.recordings.delete('recording_id')
# Nested access pattern
recording_instance = client.recordings('recording_id')
recording_data = recording_instance.get()
transcription = recording_instance.transcription.get()
recording_instance.delete()
Webhooks Resource
# List webhooks
webhooks = client.webhooks.list()
# Create webhook
webhook = client.webhooks.create(
url='https://myapp.com/webhooks',
events=['recording.completed', 'recording.failed'],
secret='optional-webhook-secret'
)
# Update webhook
client.webhooks.update(
webhook_id='webhook_id',
url='https://myapp.com/new-webhook',
events=['recording.completed']
)
# Delete webhook
client.webhooks.delete('webhook_id')
# Verify webhook signature (standalone)
from vocafuse import RequestValidator
validator = RequestValidator('your-webhook-secret')
is_valid = validator.validate(payload, signature)
API Keys Resource
# List API keys
keys = client.api_keys.list()
# Create new API key
new_key = client.api_keys.create(name='Production Key')
print(f"Key: {new_key['data']['key']}")
print(f"Secret: {new_key['data']['secret']}")
# Delete API key
client.api_keys.delete('key_id')
Account Resource
# Get account info
account = client.account.get()
print(f"Account: {account['data']['name']}")
print(f"Tenant ID: {account['data']['tenant_id']}")
# Update account
client.account.update(name='New Company Name')
Webhook Verification
from flask import Flask, request, jsonify
from vocafuse import Client, RequestValidator
app = Flask(__name__)
client = Client(
api_key='your-api-key',
api_secret='your-api-secret'
)
webhook_validator = RequestValidator('your-webhook-secret')
@app.route('/webhooks/vocafuse', methods=['POST'])
def handle_webhook():
payload = request.get_data(as_text=True)
signature = request.headers.get('X-VocaFuse-Signature')
if webhook_validator.validate(payload, signature):
# Process webhook
data = request.get_json()
print(f"Webhook event: {data['event']}")
return jsonify({"status": "received"})
else:
return jsonify({"error": "Invalid signature"}), 401
Error Handling
The SDK provides specific exceptions for different error scenarios:
from vocafuse import (
Client,
VocaFuseError,
AuthenticationError,
ValidationError,
RecordingNotFoundError,
WebhookNotFoundError
)
try:
recording = client.recordings.get('invalid-id')
except RecordingNotFoundError as e:
print(f"Recording not found: {e}")
print(f"Status code: {e.status_code}")
print(f"Error code: {e.error_code}")
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except VocaFuseError as e:
print(f"General API error: {e}")
Examples
See examples/complete_usage.py for a comprehensive example demonstrating all SDK features.
# Set environment variables
export VOCAFUSE_API_KEY="your-api-key"
export VOCAFUSE_API_SECRET="your-api-secret"
# Run the complete example
python examples/complete_usage.py
Environment Variables
VOCAFUSE_API_KEY=your_api_key_here
VOCAFUSE_API_SECRET=your_api_secret_here
VOCAFUSE_WEBHOOK_SECRET=your_webhook_secret_here # For webhook verification
Requirements
- Python 3.7+
- requests >= 2.25.0
Support
- 📧 Email: support@vocafuse.com
- 📖 Documentation: https://docs.vocafuse.com
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vocafuse-0.1.1.tar.gz.
File metadata
- Download URL: vocafuse-0.1.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82df90b8e4b5ba1155c81eced84669f15ba58911d8c626ba52e746469bd691b2
|
|
| MD5 |
1d4e14e889d35667252d78ec9ac0894b
|
|
| BLAKE2b-256 |
308093cac059476158d1047df22d26f2660ec0389babfe1360063052a07335bc
|
Provenance
The following attestation bundles were made for vocafuse-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on VocaFuse/vocafuse-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vocafuse-0.1.1.tar.gz -
Subject digest:
82df90b8e4b5ba1155c81eced84669f15ba58911d8c626ba52e746469bd691b2 - Sigstore transparency entry: 768660554
- Sigstore integration time:
-
Permalink:
VocaFuse/vocafuse-python@98e2a13d8df85d0dcf7c55e10d44f75f6f784b53 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/VocaFuse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@98e2a13d8df85d0dcf7c55e10d44f75f6f784b53 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vocafuse-0.1.1-py3-none-any.whl.
File metadata
- Download URL: vocafuse-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcaad13c4dcb188efd214e6fb1575823b7def43544a79a789ee332c21c5f33f8
|
|
| MD5 |
180a8532cf48ee550eae5b6543111e26
|
|
| BLAKE2b-256 |
31e65e2b43d9c8b6a4b6e30722f791054cdbade762e6d6f2c57fb7d97264fbe7
|
Provenance
The following attestation bundles were made for vocafuse-0.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on VocaFuse/vocafuse-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vocafuse-0.1.1-py3-none-any.whl -
Subject digest:
bcaad13c4dcb188efd214e6fb1575823b7def43544a79a789ee332c21c5f33f8 - Sigstore transparency entry: 768660555
- Sigstore integration time:
-
Permalink:
VocaFuse/vocafuse-python@98e2a13d8df85d0dcf7c55e10d44f75f6f784b53 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/VocaFuse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@98e2a13d8df85d0dcf7c55e10d44f75f6f784b53 -
Trigger Event:
release
-
Statement type: