API Documentation

Complete reference for the REST and WebSocket APIs.

Base URL

https://local.jmw.nz:41443

All REST endpoints are served over HTTPS. The server binds to 127.0.0.1 only.

REST Endpoints

GET /

Health check. Returns service info and available endpoints.

curl https://local.jmw.nz:41443/
Response
{
  "success": true,
  "service": "HapticWebPlugin",
  "version": "1.0.0",
  "endpoints": {
    "/": "Health check",
    "/waveforms": "List available waveforms",
    "/haptic/{waveform}": "Trigger haptic (POST)",
    "/ws": "WebSocket endpoint"
  }
}
GET /waveforms

List all available haptic waveforms.

curl https://local.jmw.nz:41443/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 https://local.jmw.nz:41443/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

wss://local.jmw.nz:41443/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('wss://local.jmw.nz:41443/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