VRCLS提供了丰富的REST API接口,用于程序配置、状态监控、功能控制等。所有API都通过Flask Web服务器提供,默认运行在本地端口。
- 基础URL:
http://localhost:5000/api - 内容类型:
application/json - 认证方式: 无(本地服务)
GET /api/getConfig响应示例:
{
"userInfo": {
"username": "user",
"password": "pass"
},
"baseurl": "https://whisper.boyqiu001.cn:7070",
"port": 9000,
"ip": "127.0.0.1",
"defaultMode": "control"
}POST /api/saveConfig
Content-Type: application/json
{
"userInfo": {
"username": "newuser",
"password": "newpass"
},
"baseurl": "https://newserver.com:7070"
}POST /api/saveandreboot
Content-Type: application/json
{
"config": {
// 配置数据
}
}GET /api/closewindowGET /api/maximizeGET /api/minimizeGET /api/windowrestoreGET /api/toggleMicAudioGET /api/toggleDesktopAudioGET /api/vadCalibrateGET /api/getMics响应示例:
[
{
"name": "麦克风 (Realtek High Definition Audio)",
"index": 0
},
{
"name": "虚拟麦克风",
"index": 1
}
]GET /api/getOutputsGET /api/getcaptureGET /api/getAvatarParameters响应示例:
[
{
"name": "TailCloud",
"type": "float",
"value": 0.0
},
{
"name": "Voice",
"type": "bool",
"value": true
}
]POST /api/sendTextandTranslate
Content-Type: application/json
{
"text": "Hello world",
"sourceLanguage": "en",
"targetLanguage": "zh"
}GET /api/version响应示例:
{
"version": "1.0.0",
"build": "20231201"
}GET /api/stats响应示例:
{
"uptime": 3600,
"memory_usage": 1024000,
"cpu_usage": 15.5,
"requests_processed": 1500
}GET /api/getUpdateGET /api/rebootGET /api/upgradeconst socket = io('http://localhost:5000');
socket.on('connect', () => {
console.log('Connected to VRCLS');
});socket.on('log', (data) => {
console.log('Log:', data.message);
});socket.on('status', (data) => {
console.log('Status:', data.status);
});{
"error": true,
"message": "错误描述",
"code": 400
}400: 请求参数错误404: 接口不存在500: 服务器内部错误
// 获取配置
async function getConfig() {
const response = await fetch('/api/getConfig');
const config = await response.json();
return config;
}
// 保存配置
async function saveConfig(config) {
const response = await fetch('/api/saveConfig', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(config)
});
return response.json();
}
// 切换麦克风
async function toggleMic() {
const response = await fetch('/api/toggleMicAudio');
return response.json();
}import requests
# 获取配置
def get_config():
response = requests.get('http://localhost:5000/api/getConfig')
return response.json()
# 保存配置
def save_config(config):
response = requests.post('http://localhost:5000/api/saveConfig',
json=config)
return response.json()
# 切换麦克风
def toggle_mic():
response = requests.get('http://localhost:5000/api/toggleMicAudio')
return response.json()- 本地服务: 所有API都是本地服务,不需要网络连接
- 端口配置: 默认端口为5000,可在配置中修改
- CORS: 支持跨域请求,但主要用于本地开发
- 安全性: 由于是本地服务,没有额外的安全验证
- 性能: API响应时间通常在毫秒级别
- v1.0.0: 初始版本,包含基础配置和音频控制API
- v1.1.0: 新增VRChat集成API
- v1.2.0: 新增WebSocket实时通信
- v1.3.0: 新增系统监控和统计API