支持中心/SDK 与 API 文档

HTTP API

Inverse Service HTTP API 提供 RESTful 接口用于设备发现、配置管理和状态查询。通过 HTTP 接口可以远程控制和监控 Haply 设备。

服务器端点

HTTP API 服务运行在本地端口 10001 上。

基础 URL: http://localhost:10001/

端点方法描述
/GET健康检查
/sessionsGET列出所有会话
/sessions/{selector}GET查询单个会话
/inverse3/{id}/config/{key}GET/POST设备配置
/inverse3/{id}/state/{key}GET/POST设备状态

会话管理

通过会话管理端点可以查看和定位不同应用程序创建的会话。

                # 列出所有会话
curl http://localhost:10001/sessions

# 直接查询单个会话(路径形式选择器)
curl http://localhost:10001/sessions/:myapp:0

# 查询命名空间中的第一个会话(通配符)
curl http://localhost:10001/sessions/co.haply.hub::*:0
              

端点参考

以下是常用的 HTTP API 端点示例。

                # 设置预设
curl -X POST "http://localhost:10001/inverse3/049D/config/preset?session=:0" \
     -d '{"preset":"arm_front_centered"}'

# 设置坐标系
curl -X POST "http://localhost:10001/inverse3/0/config/basis?session=myapp:0" \
     -H "Content-Type: application/json" \
     -d '{"permutation": "XZY"}'

# 设置挂载变换
curl -X POST "http://localhost:10001/inverse3/049D/config/mount?session=:0" \
     -H "Content-Type: application/json" \
     -d '{"transform":{"position":{"x":0,"y":0,"z":0},"rotation":{"w":1,"x":0,"y":0,"z":0},"scale":{"x":1,"y":1,"z":1}}}'

# 设置阻尼滤波器
curl -X POST "http://localhost:10001/inverse3/049D/config/filters/damping?session=:0" \
     -d '{"scalar": 0.5}'

# 设置力门滤波器
curl -X POST "http://localhost:10001/inverse3/049D/config/filters/force_gate?session=:0" \
     -d '{"gain": 0.5}'

# 设置设备变换状态
curl -X POST "http://localhost:10001/inverse3/049D/state/transform?session=:0" \
     -H "Content-Type: application/json" \
     -d '{"transform":{"position":{"x":1,"y":0,"z":0},"rotation":{"w":1,"x":0,"y":0,"z":0},"scale":{"x":1,"y":1,"z":1}}}'

# 设置导航模式
curl -X POST "http://localhost:10001/inverse3/04C3/config/navigation?session=:0" \
     -H "Content-Type: application/json" \
     -d '{"mode": "bubble"}'

# 删除导航配置
curl -X DELETE "http://localhost:10001/inverse3/04C3/config/navigation?session=:0"
              

内容类型

所有带有正文的 HTTP 请求都必须发送 Content-Type: application/json。

未知键将被静默忽略

该服务目前会忽略未识别的 JSON 键,且不会报错。如果某个命令似乎没有生效,请检查服务日志,并对照 API 参考文档核对字段名称。计划在未来版本中更改此行为(未知键将触发警告事件)。