Client-Side SDKs
The VocaFuse Client-Side SDKs allow you to add voice recording and transcription capabilities directly into your web and mobile applications.
Available SDKs
VocaFuse currently provides:
- JavaScript SDK - Enables voice recording in web browsers and Electron apps with automatic upload and transcription
Requirements
Building an application with the VocaFuse Client-Side SDK requires:
- A VocaFuse Account with API credentials
- API Keys (API Key and API Secret pair)
- A backend endpoint that generates JWT tokens for your users
- This endpoint authenticates your users and generates short-lived JWT tokens
- The Client-Side SDK uses these tokens to securely upload a recording
- The VocaFuse JavaScript SDK installed in your client application
- The VocaFuse Backend SDK (optional but recommended) to simplify token generation
JWT Tokens
JWT tokens serve as the credentials for your end users and are the key piece that connects your client application, VocaFuse's API, and your backend server.
JWT tokens are generated by your backend application and contain information that VocaFuse needs to:
- Associate voice recordings with the correct VocaFuse account
- Identify the end user creating the recording
- Ensure tokens expire at the proper time for security
Token Generation Flow
A typical implementation handles JWT token generation as follows:
- Your backend application has an endpoint (e.g.,
/api/vocafuse-token) - Your client-side application sends a request to this endpoint to retrieve a JWT token
- Your backend receives the request, authenticates the user, and generates a JWT token using your API credentials
- Your backend sends the token in the response
- Your client-side application receives the token and uses it to initialize the VocaFuse SDK
Example Token Endpoint
- Python
- Node.js
from flask import Flask, jsonify
from vocafuse import Client
app = Flask(__name__)
@app.route('/api/vocafuse-token')
def get_token():
# Authenticate your user here
user_id = get_current_user_id()
# Generate JWT token
client = Client(
api_key='sk_live_...',
api_secret='...'
)
token = client.generate_token(identity=user_id)
return jsonify({'token': token})
const express = require('express');
const { AccessToken } = require('vocafuse-node');
const app = express();
app.post('/api/vocafuse-token', async (req, res) => {
// Authenticate your user here
const userId = getCurrentUserId();
// Generate JWT token
const token = new AccessToken({
apiKey: process.env.VOCAFUSE_API_KEY,
apiSecret: process.env.VOCAFUSE_API_SECRET,
identity: String(userId),
});
const response = await token.generate({ expiresIn: 3600 });
res.json(response.data);
});
Security Note
Never expose your API Secret in client-side code. JWT tokens must always be generated on your backend server where your API credentials are secure.
Next Steps
- Get started with the JavaScript SDK
- View the Backend SDK documentation for token generation helpers
- Learn about webhooks to receive notifications when transcriptions complete