# Power Factor & AC Power API
> AC power triangle and power-factor maths as an API, computed locally and deterministically. The power-factor endpoint solves the power triangle: from any two of the apparent power S (volt-amperes), the real power P (watts), the reactive power Q (VAR), the power factor (cos φ) or the phase angle it returns all of them, using S = √(P²+Q²), P = S·cosφ, Q = S·sinφ and PF = P/S. The load endpoint computes the powers of a load directly from its voltage, current and power factor — single-phase S = V·I or three-phase S = √3·V·I from line values. The correction endpoint sizes power-factor correction: the reactive power a capacitor must supply to raise the power factor from a present value to a target, Qc = P·(tanφ1 − tanφ2), and — given the supply voltage and frequency — the capacitance, C = Qc/(2π·f·V²), the basis of cutting reactive demand and utility penalties. Everything is computed locally and deterministically, so it is instant and private. Ideal for electrical-engineering and power-systems tools, motor, industrial and HVAC load analysis, energy-billing and power-quality apps. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is AC power and power-factor correction; for Ohm's law, reactance and resonance use an Ohm's-law 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/powerfactor-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 30,000 calls/Mo, 6 req/s
- **Pro** ($24/Mo) — 200,000 calls/Mo, 20 req/s
- **Mega** ($75/Mo) — 1,500,000 calls/Mo, 60 req/s

## Endpoints

### Power

#### `GET /v1/correction` — Power-factor correction

**Parameters:**
- `real_power` (query, required, string) — Real power P (W) Example: `8000`
- `current_power_factor` (query, required, string) — Present power factor pf1 Example: `0.8`
- `target_power_factor` (query, required, string) — Target power factor pf2 Example: `0.95`
- `voltage` (query, optional, string) — Supply voltage (for capacitance) Example: `230`
- `frequency` (query, optional, string) — Frequency (Hz) Example: `50`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/powerfactor-api/v1/correction?real_power=8000&current_power_factor=0.8&target_power_factor=0.95&voltage=230&frequency=50"
```

**Response:**
```json
{
    "data": {
        "formula": "Qc = P·(tanφ1 − tanφ2); C = Qc/(2π·f·V²).",
        "voltage_v": 230,
        "frequency_hz": 50,
        "real_power_w": 8000,
        "capacitance_f": 0.000202811364,
        "capacitance_uf": 202.811364,
        "target_power_factor": 0.95,
        "current_power_factor": 0.8,
        "reactive_power_after_var": 2629.472841,
        "reactive_power_before_var": 6000,
        "capacitor_reactive_power_var": 3370.527159
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:40.683Z",
        "request_id": "b44fd22c-0f14-4366-9523-74e050165c79"
    },
    "status": "ok",
    "message": "Power-factor correction",
    "success": true
}
```

#### `GET /v1/load` — Power from voltage & current

**Parameters:**
- `voltage` (query, required, string) — Voltage V Example: `230`
- `current` (query, required, string) — Current I (A) Example: `10`
- `power_factor` (query, optional, string) — Power factor (default 1) Example: `0.8`
- `phase` (query, optional, string) — single | three (phase) Example: `single`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/powerfactor-api/v1/load?voltage=230&current=10&power_factor=0.8&phase=single"
```

**Response:**
```json
{
    "data": {
        "phase": "single-phase",
        "formula": "S = V·I; P = S·PF.",
        "current_a": 10,
        "voltage_v": 230,
        "power_type": "reactive load",
        "power_factor": 0.8,
        "real_power_w": 1840,
        "phase_angle_deg": 36.869898,
        "apparent_power_va": 2300,
        "reactive_power_var": 1380
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:40.766Z",
        "request_id": "d94872c3-fd37-4e75-b6e0-dfc6f5998393"
    },
    "status": "ok",
    "message": "Power from voltage & current",
    "success": true
}
```

#### `GET /v1/power-factor` — AC power triangle

**Parameters:**
- `real_power` (query, optional, string) — Real power P (W) Example: `8000`
- `apparent_power` (query, optional, string) — Apparent power S (VA)
- `reactive_power` (query, optional, string) — Reactive power Q (VAR)
- `power_factor` (query, optional, string) — Power factor cos φ Example: `0.8`
- `phase_angle` (query, optional, string) — Or phase angle (deg)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/powerfactor-api/v1/power-factor?real_power=8000&power_factor=0.8"
```

**Response:**
```json
{
    "data": {
        "formula": "S = √(P²+Q²); P = S·cosφ; Q = S·sinφ; PF = P/S = cosφ.",
        "power_type": "reactive load",
        "power_factor": 0.8,
        "real_power_w": 8000,
        "phase_angle_deg": 36.869898,
        "apparent_power_va": 10000,
        "reactive_power_var": 6000
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:40.866Z",
        "request_id": "30134fb8-0bec-4355-9b77-540397a4898e"
    },
    "status": "ok",
    "message": "AC power triangle",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "powerfactor",
        "note": "AC power triangle & power factor — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/power-factor",
            "/v1/load",
            "/v1/correction",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:40.971Z",
        "request_id": "f9506518-e19b-43a0-b224-3c3bcd746026"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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