# Music Theory API
> Music-theory maths as an API, in equal temperament with A4 = 440 Hz and scientific pitch notation (C4 = middle C = MIDI 60). The note endpoint converts freely between a note name (A4, C#5, Eb3), a MIDI note number and a frequency — and when you pass a frequency it returns the nearest note and how many cents sharp or flat it is. The interval endpoint gives the distance between two notes in semitones and cents, its name (perfect fifth, major third, …) and the exact frequency ratio. The chord endpoint returns the notes, MIDI numbers and frequencies of a chord from a root and a quality (major, minor, dim, aug, sus, 6, 7, maj7, m7, dim7, m7b5, 9 and more). The scale endpoint returns the notes of a scale or mode from a root — major, the three minor scales, the seven church modes, the major and minor pentatonics, blues, whole-tone and chromatic. Sharp or flat spelling is selectable. Everything is computed locally and deterministically, so it is instant and private. Ideal for music apps and games, synthesizers and DAWs, ear-training and theory teaching, tuners and MIDI tools. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 5 endpoints. This is music theory; for searching tracks and artists use a music API and for the classical repertoire use a classical-music 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/musicnote-api/..."
```

## Pricing
- **Free** (Free) — 6,735 calls/Mo, 2 req/s
- **Starter** ($8/Mo) — 16,250 calls/Mo, 8 req/s
- **Pro** ($28/Mo) — 213,500 calls/Mo, 20 req/s
- **Mega** ($66/Mo) — 1,110,000 calls/Mo, 50 req/s

## Endpoints

### Music

#### `GET /v1/chord` — Chord notes from root + quality

**Parameters:**
- `root` (query, required, string) — Root note Example: `C4`
- `quality` (query, optional, string) — major|minor|maj7|m7|dom7|dim|aug|sus4 Example: `maj7`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/musicnote-api/v1/chord?root=C4&quality=maj7"
```

**Response:**
```json
{
    "data": {
        "root": "C4",
        "notes": [
            {
                "midi": 60,
                "note": "C4",
                "enharmonic": null,
                "frequency_hz": 261.6256
            },
            {
                "midi": 64,
                "note": "E4",
                "enharmonic": null,
                "frequency_hz": 329.6276
            },
            {
                "midi": 67,
                "note": "G4",
                "enharmonic": null,
                "frequency_hz": 391.9954
            },
            {
                "midi": 71,
                "note": "B4",
                "enharmonic": null,
                "frequency_hz": 493.8833
            }
        ],
        "quality": "maj7",
        "intervals": [
            0,
            4,
            7,
            11
        ]
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:11.840Z",
        "request_id": "f9d22f3c-0b4d-48de-a507-76a85db56e61"
    },
    "status": "ok",
    "message": "Chord",
    "success": true
}
```

#### `GET /v1/interval` — Interval between two notes

**Parameters:**
- `from` (query, required, string) — A note Example: `C4`
- `to` (query, required, string) — A note Example: `G4`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/musicnote-api/v1/interval?from=C4&to=G4"
```

**Response:**
```json
{
    "data": {
        "to": "G4",
        "from": "C4",
        "cents": 700,
        "interval": "perfect fifth",
        "semitones": 7,
        "frequency_ratio": 1.498307
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:11.972Z",
        "request_id": "c4c72817-833a-4db0-8010-8f6a451a9828"
    },
    "status": "ok",
    "message": "Interval",
    "success": true
}
```

#### `GET /v1/note` — Note / MIDI / frequency

**Parameters:**
- `note` (query, optional, string) — Name or MIDI number Example: `A4`
- `frequency` (query, optional, string) — Or a frequency in Hz
- `flats` (query, optional, string) — Spell with flats

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/musicnote-api/v1/note?note=A4"
```

**Response:**
```json
{
    "data": {
        "midi": 69,
        "note": "A4",
        "enharmonic": null,
        "frequency_hz": 440
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:12.051Z",
        "request_id": "c65a912a-abac-4220-99a5-618abdc91063"
    },
    "status": "ok",
    "message": "Note",
    "success": true
}
```

#### `GET /v1/scale` — Scale notes from root + type

**Parameters:**
- `root` (query, required, string) — Root note Example: `C4`
- `scale` (query, optional, string) — major|minor|dorian|pentatonic_minor Example: `major`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/musicnote-api/v1/scale?root=C4&scale=major"
```

**Response:**
```json
{
    "data": {
        "root": "C4",
        "notes": [
            {
                "midi": 60,
                "note": "C4",
                "enharmonic": null,
                "frequency_hz": 261.6256
            },
            {
                "midi": 62,
                "note": "D4",
                "enharmonic": null,
                "frequency_hz": 293.6648
            },
            {
                "midi": 64,
                "note": "E4",
                "enharmonic": null,
                "frequency_hz": 329.6276
            },
            {
                "midi": 65,
                "note": "F4",
                "enharmonic": null,
                "frequency_hz": 349.2282
            },
            {
                "midi": 67,
                "note": "G4",
                "enharmonic": null,
                "frequency_hz": 391.9954
            },
            {
                "midi": 69,
                "note": "A4",
                "enharmonic": null,
                "frequency_hz": 440
            },
            {
                "midi": 71,
                "note": "B4",
                "enharmonic": null,
                "frequency_hz": 493.8833
            },
            {
                "midi": 72,
                "note": "C5",
                "enharmonic": null,
                "frequency_hz": 523.2511
            }
        ],
        "scale": "major",
        "intervals": [
            0,
            2,
            4,
            5,
            7,
  
…(truncated, see openapi.json for full schema)
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Music Theory API",
        "notes": "Equal temperament, A4 = 440 Hz. MIDI 0-127. C4 = middle C = MIDI 60. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/note",
                "params": {
                    "note": "name or MIDI number",
                    "flats": "spell with flats",
                    "frequency": "or a frequency in Hz"
                },
                "returns": "note name, MIDI number and frequency (and cents-off for a frequency)"
            },
            {
                "path": "/v1/interval",
                "params": {
                    "to": "a note",
                    "from": "a note"
                },
                "returns": "semitones, cents, interval name and frequency ratio"
            },
            {
                "path": "/v1/chord",
                "params": {
                    "root": "root note",
                    "quality": "major|minor|maj7|m7|dom7|dim|aug|sus4|…"
                },
                "returns": "the chord's notes"
            },
            {
                "path": "/v1/scale",
                "params": {
                    "root": "root note",
                    "scale": "major|minor|dorian|pentatonic_minor|…"
                },
                "returns": "the scale's notes"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "
…(truncated, see openapi.json for full schema)
```


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