# Golden Ratio & Scale API
> Design-proportion maths as an API, computed locally and deterministically. The divide endpoint splits a length by the golden section, the division beloved of artists and designers in which the whole is to the longer part as the longer is to the shorter, both ratios equal to φ = (1+√5)/2 ≈ 1.618 — so 100 splits into a 61.8 longer segment and a 38.2 shorter one — and can also extend a single segment to its larger or smaller golden partner. The rectangle endpoint gives the other side and the area of a golden rectangle from either side, the shape that leaves a smaller golden rectangle when you remove a square. The scale endpoint builds a modular (typographic) scale — base · ratio^step across a range of steps up and down — for harmonious type sizes and spacing, taking a numeric ratio or a named musical one such as minor-third (1.2), major-third (1.25), perfect-fourth (1.333) or golden (φ); a 16-base major-third scale gives 16, 20, 25, 31.25 and so on. Lengths are unit-agnostic. Everything is computed locally and deterministically, so it is instant and private. Ideal for graphic-design, web-design, UI, typography, layout and architecture app developers, type-scale and proportion tools, and design systems. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is proportion and scale; for pixel-density and print sizing use a PPI/DPI 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/goldenratio-api/..."
```

## Pricing
- **Free** (Free) — 6,400 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 64,000 calls/Mo, 6 req/s
- **Pro** ($14/Mo) — 295,000 calls/Mo, 15 req/s
- **Mega** ($44/Mo) — 1,560,000 calls/Mo, 40 req/s

## Endpoints

### GoldenRatio

#### `GET /v1/divide` — Golden section of a length

**Parameters:**
- `length` (query, optional, string) — Length to split Example: `100`
- `part` (query, optional, string) — Or a segment to extend

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/goldenratio-api/v1/divide?length=100"
```

**Response:**
```json
{
    "data": {
        "note": "Golden section: a length is split so whole/longer = longer/shorter = φ. longer ≈ 0.618·whole, shorter ≈ 0.382·whole.",
        "ratio": 1.61803399,
        "inputs": {
            "length": 100
        },
        "longer_segment": 61.803399,
        "shorter_segment": 38.196601
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:18.726Z",
        "request_id": "57a6173a-4e8c-4715-b189-ac2dae66bc49"
    },
    "status": "ok",
    "message": "Golden section",
    "success": true
}
```

#### `GET /v1/rectangle` — Golden rectangle

**Parameters:**
- `short_side` (query, optional, string) — Short side Example: `100`
- `long_side` (query, optional, string) — Or long side

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/goldenratio-api/v1/rectangle?short_side=100"
```

**Response:**
```json
{
    "data": {
        "area": 16180.339887,
        "note": "Golden rectangle: long side = short · φ. Removing a square leaves a smaller golden rectangle.",
        "inputs": {
            "short_side": 100
        },
        "long_side": 161.803399
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:18.828Z",
        "request_id": "a02f991c-6a65-4bad-8c36-549d4ef88c21"
    },
    "status": "ok",
    "message": "Golden rectangle",
    "success": true
}
```

#### `GET /v1/scale` — Modular type scale

**Parameters:**
- `base` (query, required, string) — Base value (e.g. font size) Example: `16`
- `ratio` (query, optional, string) — Numeric ratio
- `ratio_name` (query, optional, string) — minor-third, major-third, perfect-fourth, golden… Example: `major-third`
- `steps_up` (query, optional, string) — Steps up (default 5) Example: `5`
- `steps_down` (query, optional, string) — Steps down (default 2) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/goldenratio-api/v1/scale?base=16&ratio_name=major-third&steps_up=5&steps_down=2"
```

**Response:**
```json
{
    "data": {
        "note": "Modular scale value = base · ratio^step. Used for typographic and spacing scales; common ratios include major-third (1.25), perfect-fourth (1.333) and golden (φ≈1.618).",
        "steps": [
            {
                "step": -2,
                "value": 10.24
            },
            {
                "step": -1,
                "value": 12.8
            },
            {
                "step": 0,
                "value": 16
            },
            {
                "step": 1,
                "value": 20
            },
            {
                "step": 2,
                "value": 25
            },
            {
                "step": 3,
                "value": 31.25
            },
            {
                "step": 4,
                "value": 39.0625
            },
            {
                "step": 5,
                "value": 48.828125
            }
        ],
        "inputs": {
            "base": 16,
            "ratio": 1.25,
            "ratio_name": "major-third"
        }
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:18.952Z",
        "request_id": "f401e94e-5850-4e68-84ba-8ea1fac7c8fd"
    },
    "status": "ok",
    "message": "Modular scale",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "phi": 1.61803398875,
        "notes": "φ = (1+√5)/2 ≈ 1.618. Lengths are unit-agnostic. The scale takes a numeric ratio or a named one (major-third, perfect-fourth, golden…).",
        "ratios": [
            "minor-second",
            "major-second",
            "minor-third",
            "major-third",
            "perfect-fourth",
            "augmented-fourth",
            "perfect-fifth",
            "golden",
            "phi"
        ],
        "service": "goldenratio-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/scale": "Modular (typographic) scale from a base, ratio and step range.",
            "GET /v1/divide": "Split a length by the golden section, or extend a segment.",
            "GET /v1/rectangle": "Golden rectangle's other side and area."
        },
        "description": "Design proportions: golden section, golden rectangle, and the modular/typographic scale."
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:19.055Z",
        "request_id": "30138ad4-bcc3-4145-8f10-be00c3159d6e"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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