API Documentation

Complete reference for the REST and WebSocket APIs.

Base URL

http://127.0.0.1:41080

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

GET /

Health check. Confirms the haptics service is running.

curl http://127.0.0.1:41080/
Response
{
  "success": true,
  "service": "HapticWebPlugin"
}
GET /waveforms

List all available haptic waveforms.

curl http://127.0.0.1:41080/waveforms
Response
{
  "success": true,
  "count": 16,
  "waveforms": [
    "sharp_collision",
    "sharp_state_change",
    "knock",
    ...
  ]
}
POST /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.

IndexAPI NameCategory
0sharp_collisionPrecision enhancers
1sharp_state_changeProgress indicators
2knockIncoming events
3damp_collisionPrecision enhancers
4madProgress indicators
5ringingIncoming events
6subtle_collisionPrecision enhancers
7completedProgress indicators
8jingleIncoming events
9damp_state_changePrecision enhancers
10fireworkProgress indicators
11happy_alertProgress indicators
12waveProgress indicators
13angry_alertProgress indicators
14squareProgress 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.