# Draft Beer API
> Draft-beer dispense maths as an API, computed locally and deterministically — the CO₂ pressure and beer-line numbers a homebrewer, kegerator owner or bar sets a tap by. (This is the serving side; for ABV, gravity and IBU that is a homebrewing calculation.) The carbonation endpoint gives the regulator head pressure that holds a target carbonation at the serving temperature, from the standard volumes-temperature-pressure regression: 2.5 volumes of CO₂ at 38 °F needs about 11 psi, and colder beer holds the same carbonation at a lower pressure — British ales sit around 1.5–2.0 volumes, US ales 2.2–2.7, lagers and wheats higher. The balance endpoint sizes the beer line so the system pours a clean head instead of foaming or pouring slow: line length = (applied pressure − 0.5 × rise − residual) ÷ the line’s resistance per foot, where gravity adds about 0.5 psi per foot of lift and roughly 1 psi is left at the faucet — so 12 psi with no rise on 3/16-inch vinyl (≈3 psi/ft) wants about 3.7 feet, while narrower or wider tubing changes everything. Everything is computed locally and deterministically, so it is instant and private. Ideal for homebrew, kegerator, bar, brewery-taproom and beverage app developers, draft-system and troubleshooting tools, and hospitality software. Pure local computation — no key, no third-party service, instant. Dispense side only. Live, nothing stored. 2 compute endpoints.

## 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/draftbeer-api/..."
```

## Pricing
- **Free** (Free) — 7,200 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 56,300 calls/Mo, 6 req/s
- **Pro** ($12/Mo) — 230,500 calls/Mo, 15 req/s
- **Mega** ($37/Mo) — 1,344,000 calls/Mo, 40 req/s

## Endpoints

### Draft

#### `GET /v1/balance` — Beer-line balancing

**Parameters:**
- `pressure_psi` (query, required, string) — Applied/regulator pressure (psi) Example: `12`
- `rise_ft` (query, optional, string) — Vertical lift keg→faucet (ft) Example: `0`
- `line` (query, optional, string) — 3/16-vinyl, 1/4-vinyl, 3/16-poly, … Example: `3/16-vinyl`
- `resistance_psi_per_ft` (query, optional, string) — Custom line resistance (psi/ft)
- `faucet_residual_psi` (query, optional, string) — Residual at faucet (default 1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/draftbeer-api/v1/balance?pressure_psi=12&rise_ft=0&line=3%2F16-vinyl&faucet_residual_psi=1"
```

**Response:**
```json
{
    "data": {
        "note": "Line length = (applied pressure − 0.5 × rise − residual) ÷ line resistance per foot. Gravity adds ~0.5 psi per foot of lift; ~1 psi residual is left at the faucet. A balanced line pours a proper head with no foaming or over-restriction. If length is ≤ 0, use a higher-resistance (narrower) line.",
        "inputs": {
            "rise_ft": 0,
            "pressure_psi": 12,
            "faucet_residual_psi": 1,
            "resistance_psi_per_ft": 3
        },
        "balanced": true,
        "line_length_m": 1.12,
        "line_length_ft": 3.67
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:00.143Z",
        "request_id": "02148117-40f8-4ed4-9538-188bcc457770"
    },
    "status": "ok",
    "message": "Line balance",
    "success": true
}
```

#### `GET /v1/carbonation` — CO₂ pressure for carbonation

**Parameters:**
- `volumes` (query, required, string) — Target CO₂ volumes Example: `2.5`
- `temperature` (query, required, string) — Serving temperature Example: `38`
- `temp_unit` (query, optional, string) — f or c (default f) Example: `f`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/draftbeer-api/v1/carbonation?volumes=2.5&temperature=38&temp_unit=f"
```

**Response:**
```json
{
    "data": {
        "note": "Regulator head pressure to hold the target CO₂ volumes at the serving temperature (the gas equilibrium). Colder beer holds CO₂ at lower pressure. British ales ~1.5–2.0 vols, US ales ~2.2–2.7, lagers ~2.4–2.8, many lagers/wheats higher.",
        "inputs": {
            "volumes": 2.5,
            "temp_unit": "f",
            "temperature_f": 38
        },
        "pressure_bar": 0.78,
        "pressure_kpa": 77.5,
        "pressure_psi": 11.2
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:00.221Z",
        "request_id": "414c3b58-cdfe-45ea-8157-0607914d8060"
    },
    "status": "ok",
    "message": "Carbonation pressure",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Dispense side only (not brewing). Carbonation uses the standard volumes/temperature/pressure regression. Balance: length = (pressure − 0.5·rise − residual) ÷ resistance/ft; 3/16\" vinyl ≈ 3 psi/ft. For ABV, gravity or IBU use a homebrewing API.",
        "service": "draftbeer-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/balance": "Beer-line length to balance a system from pressure, rise and line resistance.",
            "GET /v1/carbonation": "Regulator CO₂ pressure for a target carbonation (volumes) at serving temperature."
        },
        "description": "Draft-beer dispense maths: CO₂ head pressure for a target carbonation at temperature, and beer-line balancing."
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:00.312Z",
        "request_id": "01ad6cb6-eea3-493b-a72f-7e462f5ce7a0"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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