# PID Tuning API
> PID-controller-tuning maths as an API, computed locally and deterministically. The ziegler-nichols endpoint computes controller gains with the closed-loop (ultimate-gain) method: from the ultimate gain Ku at which the loop sustains oscillation and its period Tu it returns the proportional, integral and derivative gains for a P, PI, PD or PID controller using the classic table (PID: Kp = 0.6·Ku, Ti = 0.5·Tu, Td = 0.125·Tu), in both the standard (Ti, Td) and parallel (Ki, Kd) parameters. The reaction-curve endpoint computes gains with the open-loop method from a step-response process model — the process gain K, the dead time L and the time constant T — using the Ziegler-Nichols reaction-curve table (PID: Kp = 1.2·T/(K·L), Ti = 2L, Td = 0.5L). The convert endpoint translates between the parallel form (Kp, Ki, Kd) and the standard form (Kp, Ti, Td) using Ki = Kp/Ti and Kd = Kp·Td. Everything is computed locally and deterministically, so it is instant and private. Ideal for industrial-automation, robotics, process-control, motor-control and IoT app developers, controller-tuning and loop-design tools, and control-systems education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is PID controller tuning; for op-amp circuits use an op-amp API and for resonance and reactance a resonance API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/pid-api/..."
```

## Pricing
- **Free** (Free) — 2,850 calls/Mo, 2 req/s
- **Starter** ($10/Mo) — 41,000 calls/Mo, 6 req/s
- **Pro** ($25/Mo) — 249,000 calls/Mo, 15 req/s
- **Mega** ($72/Mo) — 1,730,000 calls/Mo, 40 req/s

## Endpoints

### PID

#### `GET /v1/convert` — PID form conversion

**Parameters:**
- `kp` (query, required, string) — Proportional gain Kp Example: `6`
- `ki` (query, optional, string) — Integral gain Ki (parallel)
- `kd` (query, optional, string) — Derivative gain Kd (parallel)
- `ti` (query, optional, string) — Integral time Ti (standard) Example: `1`
- `td` (query, optional, string) — Derivative time Td (standard) Example: `0.25`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pid-api/v1/convert?kp=6&ti=1&td=0.25"
```

**Response:**
```json
{
    "data": {
        "Kd": 1.5,
        "Ki": 6,
        "Kp": 6,
        "to": "parallel",
        "from": "standard",
        "note": "Standard → parallel: Ki = Kp/Ti, Kd = Kp·Td.",
        "inputs": {
            "kp": 6,
            "td": 0.25,
            "ti": 1
        }
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:28.463Z",
        "request_id": "67cdb044-487b-45e8-aaa6-234df7cda078"
    },
    "status": "ok",
    "message": "Form conversion",
    "success": true
}
```

#### `GET /v1/reaction-curve` — ZN open-loop tuning

**Parameters:**
- `process_gain` (query, required, string) — Process gain K Example: `2`
- `dead_time` (query, required, string) — Dead time L (s) Example: `1`
- `time_constant` (query, required, string) — Time constant T (s) Example: `5`
- `type` (query, optional, string) — P, PI or PID Example: `PID`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pid-api/v1/reaction-curve?process_gain=2&dead_time=1&time_constant=5&type=PID"
```

**Response:**
```json
{
    "data": {
        "Kd": 1.5,
        "Ki": 1.5,
        "Kp": 3,
        "Td": 0.5,
        "Ti": 2,
        "note": "Open-loop ZN from a step-response reaction curve (process gain K, dead time L, time constant T). PID: Kp=1.2·T/(K·L), Ti=2L, Td=0.5L.",
        "inputs": {
            "type": "PID",
            "dead_time": 1,
            "process_gain": 2,
            "time_constant": 5
        },
        "method": "Ziegler-Nichols open-loop (reaction curve)"
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:28.548Z",
        "request_id": "67161297-ce27-4bf0-b0fe-54db8aacdae5"
    },
    "status": "ok",
    "message": "ZN open-loop",
    "success": true
}
```

#### `GET /v1/ziegler-nichols` — ZN closed-loop tuning

**Parameters:**
- `ultimate_gain` (query, required, string) — Ultimate gain Ku Example: `10`
- `ultimate_period` (query, required, string) — Ultimate period Tu (s) Example: `2`
- `type` (query, optional, string) — P, PI, PD or PID Example: `PID`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pid-api/v1/ziegler-nichols?ultimate_gain=10&ultimate_period=2&type=PID"
```

**Response:**
```json
{
    "data": {
        "Kd": 1.5,
        "Ki": 6,
        "Kp": 6,
        "Td": 0.25,
        "Ti": 1,
        "note": "Closed-loop ZN: raise the proportional gain until sustained oscillation to find Ku and its period Tu, then apply the table (PID: Kp=0.6Ku, Ti=0.5Tu, Td=0.125Tu). Expect ~25 % overshoot; detune for less aggressive control.",
        "inputs": {
            "type": "PID",
            "ultimate_gain": 10,
            "ultimate_period": 2
        },
        "method": "Ziegler-Nichols closed-loop (ultimate gain)"
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:28.678Z",
        "request_id": "79de3ef9-39df-42c4-9e64-78b41368602f"
    },
    "status": "ok",
    "message": "ZN closed-loop",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pid-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "Ku is the ultimate gain, Tu its oscillation period; K/L/T are the process gain, dead time and time constant from a step response. type: P, PI, PD or PID.",
        "service": "pid-api",
        "formulae": {
            "forms": "Ki=Kp/Ti, Kd=Kp·Td",
            "zn_open_pid": "Kp=1.2·T/(K·L), Ti=2L, Td=0.5L",
            "zn_closed_pid": "Kp=0.6Ku, Ti=0.5Tu, Td=0.125Tu"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/convert": "Convert between parallel (Kp,Ki,Kd) and standard (Kp,Ti,Td) forms.",
            "GET /v1/reaction-curve": "Open-loop ZN gains from process gain, dead time and time constant.",
            "GET /v1/ziegler-nichols": "Closed-loop ZN gains from ultimate gain Ku and period Tu."
        },
        "description": "PID controller-tuning calculator: Ziegler-Nichols closed-loop (ultimate gain) and open-loop (reaction curve) tuning, and conversion between the parallel and standard PID forms."
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:28.791Z",
        "request_id": "a716788e-8524-4fd9-bf35-765f60b48b39"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/pid-api
OpenAPI spec: https://www.oanor.com/api/pid-api/openapi.json
