# SensorPulse localhost API

Default: `127.0.0.1` only (port 8765). Enable in SensorPulse: Settings → Automation → Localhost API.

Optional: Remote access (Companion app) also binds to LAN IPs on your home network (read-only, API token required). On the go: VPN into your home network (e.g. Tailscale), not public port forwarding.

## Endpoints

Path | Description
--- | ---
`GET /api/health` | `{"status":"ok"}`
`GET /api/sensors` | JSON array of active sensors
`GET /api/quicklook` | CPU/GPU/RAM snapshot + alert count
`GET /api/companion` | Compact mobile payload: quicklook, warnings/critical, highlights
`GET /api/alerts` | Active warnings
`GET /api/history/{sensorId}?minutes=60` | Sensor history

## Authentication

When an API token is configured, send:

    Authorization: Bearer YOUR_TOKEN

For Rainmeter on the same PC you can leave the token empty (localhost only).

## Example: quicklook

    curl http://127.0.0.1:8765/api/quicklook

    {
      "cpuLoad": 42.5,
      "gpuLoad": 68.0,
      "memoryLoad": 55.2,
      "cpuTemp": 58.0,
      "gpuTemp": 72.0,
      "activeAlerts": 0
    }

## Rainmeter

Example skin: copy `Website/downloads/rainmeter/SensorPulse/` from the repo to `%USERPROFILE%\Documents\Rainmeter\Skins\` and load it in Rainmeter.

Adjust the port in `SensorPulseQuicklook.ini` if needed.

## Companion app (remote)

For phone monitoring also enable Remote access in Settings. App endpoint: `GET /api/companion`. Full guide: `companion-setup.html` in the Help folder or button Full setup guide (browser) in Settings.

## Troubleshooting

- API won't start – port in use? Pick another (1024–65535).
- 401 unauthorized – send token header or `?token=…` in URL.
- Companion can't reach PC – remote on? firewall (private)? same Wi‑Fi/VPN?
- Empty values – monitoring paused or app just started – wait a moment.