โ† All packages
๐Ÿ“

raspberry-pi-gpio-api

The core of ctrlPi: a Python server that exposes GPIO pin control over an OpenAPI REST API. Read and write pins remotely from any HTTP client, this is the agent every other ctrlPi project talks to.

๐Ÿ Python 3.9+ ยท FastAPI ๐Ÿ”Œ Port 8314 ๐Ÿ“ Pi 2 / 3 / 4 / 5 / Zero W / Zero 2 W ๐Ÿ”‘ Api-Key auth โš–๏ธ MIT
View on GitHub ๐Ÿ“ Pi pinout

Install on your Pi

One-liner, no git required, downloads the release files, safe to re-run to update (config and logs are never touched):

# on the Pi
curl -fsSL https://raw.githubusercontent.com/ctrlpi/raspberry-pi-gpio-api/main/install.sh | bash
cd raspberry-pi-gpio-api
./run.sh     # sets up venv, installs deps, starts the server on :8314
๐Ÿ’ปNo Pi handy? It runs on Mac/PC too, a built-in mock GPIO mode kicks in automatically on non-Pi systems, so you can develop clients anywhere.

What it does

The REST API

All routes require the Api-Key header except /hello:

MethodPathDescription
GET/helloDiscovery & health check, returns the agent's name, no auth
GET/gpio/readRead all configured pins
GET/gpio/read/{name_or_gpio}Read one pin by GPIO number or name alias
POST/gpio/write/{name_or_gpio}Write a value, supports "flip" and timed duration pulses
POST/gpio/config/{name_or_gpio}Configure a pin: type, name, init, pullup, max, reversed, watched
GET/gpio/watchedList watched pins and the active webhook URL
GET/gpio/scanScan all BCM pins (Pi hardware), includes physical level, platform, CPU temp
GET/config/readAgent identity + full config
POST/config/updateUpdate config fields (auto-backup first)
POST/config/loadReplace the whole config ({} resets)
POST/restartRestart the server process, or reboot the device with {"reboot": true}
GET/logsLast 50 log lines as JSON

Try it

# configure GPIO 17 as an output named "relay", active-low
curl -X POST http://raspberrypi:8314/gpio/config/17 \
  -H "Api-Key: your-secret-key" -H "Content-Type: application/json" \
  -d '{"type": "output", "name": "relay", "reversed": true}'

# pulse it for 2 seconds, reverts automatically
curl -X POST http://raspberrypi:8314/gpio/write/relay \
  -H "Api-Key: your-secret-key" -H "Content-Type: application/json" \
  -d '{"value": 1, "duration": 2}'

Webhooks

Mark any pin watched and the agent POSTs its state to a webhook URL on every change, that's how the HomeKit and Matter bridges get real-time input events. With no URL configured it defaults to ctrlPi's test endpoint, so you can watch your events live while wiring.

In the family

This is the reference agent. pico-gpio-api speaks the identical wire format on a Pico W; the bridges and ctrlpi-mcp drive any mix of both interchangeably.