API Documentation
Complete reference for the REST and WebSocket APIs.
Base URL
The server binds to 127.0.0.1 only. Chrome and Firefox treat loopback
as a secure context, so HTTPS pages can call it directly (for Safari, see the deprecated section below).
REST Endpoints
/Health check. Confirms the haptics service is running.
curl http://127.0.0.1:41080/
Response
{
"success": true,
"service": "HapticWebPlugin"
}/waveformsList all available haptic waveforms.
curl http://127.0.0.1:41080/waveforms
Response
{
"success": true,
"count": 16,
"waveforms": [
"sharp_collision",
"sharp_state_change",
"knock",
...
]
}/haptic/{waveform}Trigger a specific haptic waveform by name.
curl -X POST http://127.0.0.1:41080/haptic/knock -d ''
Note: The -d '' is required to send a Content-Length header. Without it, curl will wait indefinitely.
Response
{
"success": true,
"waveform": "knock"
}WebSocket API
ws://127.0.0.1:41080/ws
Protocol
- Send a single byte containing the waveform index (0-15)
- No response is sent back
- Connection stays open for repeated triggers
- Binary message type (
Uint8Array)
const ws = new WebSocket('ws://127.0.0.1:41080/ws');
ws.onopen = () => {
// Trigger waveform at index 0 (sharp_collision)
ws.send(new Uint8Array([0]));
}; Available Waveforms
16 waveforms across different categories. Use the index for WebSocket, or the API name for REST.
| Index | API Name | Category |
|---|---|---|
| 0 | sharp_collision | Precision enhancers |
| 1 | sharp_state_change | Progress indicators |
| 2 | knock | Incoming events |
| 3 | damp_collision | Precision enhancers |
| 4 | mad | Progress indicators |
| 5 | ringing | Incoming events |
| 6 | subtle_collision | Precision enhancers |
| 7 | completed | Progress indicators |
| 8 | jingle | Incoming events |
| 9 | damp_state_change | Precision enhancers |
| 10 | firework | Progress indicators |
| 11 | happy_alert | Progress indicators |
| 12 | wave | Progress indicators |
| 13 | angry_alert | Progress indicators |
| 14 | square | Progress indicators |
Deprecated: HTTPS endpoint
The same API is also served on https://local.jmw.nz:41443 (WebSocket: wss://local.jmw.nz:41443/ws) for Safari, which still blocks plain ws:// requests to localhost from HTTPS pages.
Use it only when the endpoint above fails. It will be removed once Safari allows loopback requests,
or by November 2027 at the latest.