Music Theory API (v0.0.1)
Download OpenAPI specification:Download
This section is under construction. Please check back later.
Created by David Vogel
Repo: https://github.com/DavidVogel/MusicTheoryApi
Base URL: https://musictheoryapi.com
The Music Theory API is currently a toy project for me to both practice my developer skills and demonstrate technical writing knowledge around APIs, SaaS, DevOps, and InfoSec. However, in the coming months and years, I hope to turn it into something truly useful that can provide answers to a vast array of music theory questions, and will be able to generate working examples in standard formats such as MusicXML and MIDI.
The API currently provides minimal functionality for a few basic music theory questions, but since this is primarily a demonstration of technical writing at the moment, the documentation covers everything necessary for a development team to work on and support the API as well as how a client would consume it.
Currently, the API allows you to do the following:
- Get the notes of a root-position chord (major, minor, augmented, or diminished)
- Get a few common chord progressions for a key (both Roman numerals and note spellings / pitch classes)
- Get notes for a scale (major, minor, or harmonic minor)
- Get diatonic chords for a scale (major, minor, or harmonic minor)
Eventually, much more functionality will be added, including:
- Output in MusicXML and MIDI formats
- More chord types (inversions, suspensions, 7th, 9th, 11th, 13th, etc.)
- More scales (whole tone, pentatonic, hexatonic, octatonic, modes, etc.)
- More progressions (circle of fifths, secondary dominants, etc.)
- More music theory concepts (counterpoint, voice leading, etc.)
The reference documentation is generated from the source code following the OpenAPI 3.0 specification and is beautifully rendered using redocusaurus (a Redoc wrapper for Docusaurus).
In addition to the reference documentation, this page contains a Quick Start section to help you get started quickly.
The following sections are also available:
- Authentication
- SDK
We will run through the process of creating a user, obtaining a JWT token, and making calls to the API.
To start using the API, you must register using an email address and password.
Run the following command, using your own email and password, to register a new user:
curl 'https://musictheoryapi.com/api/v0/auth/register' \
--header 'Content-Type: application/json' \
--data-raw '{
"Email": "user@example.com",
"Password": "StrongPassword123"
}'
If all is well, you will receive a 201 Created
response with a message saying that the user was created successfully.
If you get a 500 error, try again a few times. Azure can be unreliable at times.
Once registered, you need to obtain a JWT token to make further requests.
Run the following command, using your own email and password, to obtain a JWT token:
curl 'https://musictheoryapi.com/api/v0/auth/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"Email": "user@example.com",
"Password": "StrongPassword123"
}'
If successful, you will receive a 200 OK
response with a JWT token in the token
field. This token is valid for one hour and must be included in the Authorization
header of all subsequent requests.
Getting the notes of a chord
First, we will get the notes of a B augmented triad. The notes for this are B, D♯, and F𝄪. To get past the burden of special characters and ambiguous URLs, we spell these things out when using the API, but in some instances (e.g., scales) it is also capable of returning a stringified response (in the case of scales) such as "B, D#, F##"
.
To get the notes of a chord (B augmented triad in this case), run the following command using your own token:
curl 'https://musictheoryapi.com/api/v0/chords/b/augmented' \
--header 'Authorization: Bearer {token}'
(to be continued...)
Register a new user
Request Body schema: application/jsonrequired
Registration model containing user details
email required | string non-empty User's email |
password required | string non-empty User's password |
Responses
Request samples
- Payload
- cURL
{- "email": "string",
- "password": "string"
}
Response samples
- 201
- 400
{- "message": "string"
}
Get a JWT token for the user
Request Body schema: application/jsonrequired
Login model containing user credentials
email required | string non-empty User's email |
password required | string non-empty User's password |
Responses
Request samples
- Payload
- cURL
{- "email": "string",
- "password": "string"
}
Response samples
- 200
- 401
{- "token": "string"
}
Get the notes of a chord specified by root and type
path Parameters
root required | string The root note of the chord (e.g. "D", "C-Sharp", "B-Flat") |
chordType required | string The chord type ("Minor", "Major", "Diminished", or "Augmented") |
Responses
Request samples
- cURL
curl 'https://musictheoryapi.com/api/v0/chords/b/augmented' \ --header 'Authorization: Bearer {token}'
Response samples
- 200
- 400
{- "root": {
- "name": "B",
- "accidental": "Natural",
- "pitchClass": 11
}, - "type": "Augmented",
- "notes": [
- {
- "name": "B",
- "accidental": "Natural",
- "pitchClass": 11
}, - {
- "name": "D",
- "accidental": "Sharp",
- "pitchClass": 3
}, - {
- "name": "F",
- "accidental": "DoubleSharp",
- "pitchClass": 7
}
]
}
Get common chord progressions for the specified key
path Parameters
root required | string The root note of the key (e.g. "E", "D-Flat", "A-Sharp") |
scaleType required | string The scale type of the key ("Minor" or "Major) |
Responses
Request samples
- cURL
curl 'https://musictheoryapi.com/api/v0/progressions/c/major/common' \ --header 'Authorization: Bearer {token}'
Response samples
- 200
- 400
[- {
- "pattern": "I-IV-V",
- "chords": [
- {
- "root": {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - "type": "Major",
- "notes": [
- {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}
]
}, - {
- "root": {
- "name": "F",
- "accidental": "Natural",
- "pitchClass": 5
}, - "type": "Major",
- "notes": [
- {
- "name": "F",
- "accidental": "Natural",
- "pitchClass": 5
}, - {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}
]
}, - {
- "root": {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - "type": "Major",
- "notes": [
- {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - {
- "name": "B",
- "accidental": "Natural",
- "pitchClass": 11
}, - {
- "name": "D",
- "accidental": "Natural",
- "pitchClass": 2
}
]
}
]
}, - {
- "pattern": "I-V-vi-IV",
- "chords": [
- {
- "root": {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - "type": "Major",
- "notes": [
- {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}
]
}, - {
- "root": {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - "type": "Major",
- "notes": [
- {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - {
- "name": "B",
- "accidental": "Natural",
- "pitchClass": 11
}, - {
- "name": "D",
- "accidental": "Natural",
- "pitchClass": 2
}
]
}, - {
- "root": {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - "type": "Minor",
- "notes": [
- {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}
]
}, - {
- "root": {
- "name": "F",
- "accidental": "Natural",
- "pitchClass": 5
}, - "type": "Major",
- "notes": [
- {
- "name": "F",
- "accidental": "Natural",
- "pitchClass": 5
}, - {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}
]
}
]
}, - {
- "pattern": "ii-V-I",
- "chords": [
- {
- "root": {
- "name": "D",
- "accidental": "Natural",
- "pitchClass": 2
}, - "type": "Minor",
- "notes": [
- {
- "name": "D",
- "accidental": "Natural",
- "pitchClass": 2
}, - {
- "name": "F",
- "accidental": "Natural",
- "pitchClass": 5
}, - {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}
]
}, - {
- "root": {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - "type": "Major",
- "notes": [
- {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}, - {
- "name": "B",
- "accidental": "Natural",
- "pitchClass": 11
}, - {
- "name": "D",
- "accidental": "Natural",
- "pitchClass": 2
}
]
}, - {
- "root": {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - "type": "Major",
- "notes": [
- {
- "name": "C",
- "accidental": "Natural",
- "pitchClass": 0
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - {
- "name": "G",
- "accidental": "Natural",
- "pitchClass": 7
}
]
}
]
}
]
Get notes in a given scale
path Parameters
root required | string The root note of the scale (e.g. "C", "G-Sharp", "B-Flat") |
scaleType required | string The type of scale (e.g. "Major", "Minor", "HarmonicMinor") |
Responses
Request samples
- cURL
curl 'https://musictheoryapi.com/api/v0/scales/G-Sharp/harmonicminor/notes' \ --header 'Authorization: Bearer {token}'
Response samples
- 200
- 400
[- "G#",
- "A#",
- "B",
- "C#",
- "D#",
- "E",
- "F##",
- "G#"
]
Get diatonic chords in a given scale
path Parameters
root required | string The root note of the scale (e.g. "C", "F-Sharp", "A-Flat") |
scaleType required | string The type of scale ("Major" or "Minor") |
Responses
Request samples
- cURL
curl 'https://musictheoryapi.com/api/v0/scales/c-sharp/harmonicminor/chords' \ --header 'Authorization: Bearer {token}'
Response samples
- 200
- 400
[- {
- "root": {
- "name": "C",
- "accidental": "Sharp",
- "pitchClass": 1
}, - "type": "Minor",
- "notes": [
- {
- "name": "C",
- "accidental": "Sharp",
- "pitchClass": 1
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - {
- "name": "G",
- "accidental": "Sharp",
- "pitchClass": 8
}
]
}, - {
- "root": {
- "name": "D",
- "accidental": "Sharp",
- "pitchClass": 3
}, - "type": "Diminished",
- "notes": [
- {
- "name": "D",
- "accidental": "Sharp",
- "pitchClass": 3
}, - {
- "name": "F",
- "accidental": "Sharp",
- "pitchClass": 6
}, - {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}
]
}, - {
- "root": {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - "type": "Augmented",
- "notes": [
- {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}, - {
- "name": "G",
- "accidental": "Sharp",
- "pitchClass": 8
}, - {
- "name": "B",
- "accidental": "Sharp",
- "pitchClass": 0
}
]
}, - {
- "root": {
- "name": "F",
- "accidental": "Sharp",
- "pitchClass": 6
}, - "type": "Minor",
- "notes": [
- {
- "name": "F",
- "accidental": "Sharp",
- "pitchClass": 6
}, - {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - {
- "name": "C",
- "accidental": "Sharp",
- "pitchClass": 1
}
]
}, - {
- "root": {
- "name": "G",
- "accidental": "Sharp",
- "pitchClass": 8
}, - "type": "Major",
- "notes": [
- {
- "name": "G",
- "accidental": "Sharp",
- "pitchClass": 8
}, - {
- "name": "B",
- "accidental": "Sharp",
- "pitchClass": 0
}, - {
- "name": "D",
- "accidental": "Sharp",
- "pitchClass": 3
}
]
}, - {
- "root": {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - "type": "Major",
- "notes": [
- {
- "name": "A",
- "accidental": "Natural",
- "pitchClass": 9
}, - {
- "name": "C",
- "accidental": "Sharp",
- "pitchClass": 1
}, - {
- "name": "E",
- "accidental": "Natural",
- "pitchClass": 4
}
]
}, - {
- "root": {
- "name": "B",
- "accidental": "Sharp",
- "pitchClass": 0
}, - "type": "Diminished",
- "notes": [
- {
- "name": "B",
- "accidental": "Sharp",
- "pitchClass": 0
}, - {
- "name": "D",
- "accidental": "Sharp",
- "pitchClass": 3
}, - {
- "name": "F",
- "accidental": "Sharp",
- "pitchClass": 6
}
]
}
]
email required | string non-empty User's email |
password required | string non-empty User's password |
{- "email": "string",
- "password": "string"
}
email required | string non-empty User's email |
password required | string non-empty User's password |
{- "email": "string",
- "password": "string"
}
required | Note (object) The root note of the chord (e.g., "C", "D-Sharp", "E-Flat", etc.) |
required | ChordType (string) The type of chord ("Major", "Minor", "Diminished", or "Augmented") |
required | Array of objects (Note) The notes of the chord (triad) generated from the root and type |
{- "Root": {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - "Type": "Augmented",
- "Notes": [
- {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - {
- "Name": "D",
- "Accidental": "Sharp",
- "PitchClass": 3
}, - {
- "Name": "F",
- "Accidental": "DoubleSharp",
- "PitchClass": 7
}
]
}
Types of triad chords
"Major"
pattern required | string non-empty The pattern of the chord progression, e.g., "I-IV-V" or "i-iv-v". |
required | Array of objects (Chord) The chords in the progression, represented as a list of Chord objects |
[- {
- "Pattern": "I-IV-V",
- "Chords": [
- {
- "Root": {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - {
- "Name": "E",
- "Accidental": "Natural",
- "PitchClass": 4
}, - {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}
]
}, - {
- "Root": {
- "Name": "F",
- "Accidental": "Natural",
- "PitchClass": 5
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "F",
- "Accidental": "Natural",
- "PitchClass": 5
}, - {
- "Name": "A",
- "Accidental": "Natural",
- "PitchClass": 9
}, - {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}
]
}, - {
- "Root": {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - {
- "Name": "D",
- "Accidental": "Natural",
- "PitchClass": 2
}
]
}
]
}, - {
- "Pattern": "I-V-vi-IV",
- "Chords": [
- {
- "Root": {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - {
- "Name": "E",
- "Accidental": "Natural",
- "PitchClass": 4
}, - {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}
]
}, - {
- "Root": {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - {
- "Name": "D",
- "Accidental": "Natural",
- "PitchClass": 2
}
]
}, - {
- "Root": {
- "Name": "A",
- "Accidental": "Natural",
- "PitchClass": 9
}, - "Type": "Minor",
- "Notes": [
- {
- "Name": "A",
- "Accidental": "Natural",
- "PitchClass": 9
}, - {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - {
- "Name": "E",
- "Accidental": "Natural",
- "PitchClass": 4
}
]
}, - {
- "Root": {
- "Name": "F",
- "Accidental": "Natural",
- "PitchClass": 5
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "F",
- "Accidental": "Natural",
- "PitchClass": 5
}, - {
- "Name": "A",
- "Accidental": "Natural",
- "PitchClass": 9
}, - {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}
]
}
]
}, - {
- "Pattern": "ii-V-I",
- "Chords": [
- {
- "Root": {
- "Name": "D",
- "Accidental": "Natural",
- "PitchClass": 2
}, - "Type": "Minor",
- "Notes": [
- {
- "Name": "D",
- "Accidental": "Natural",
- "PitchClass": 2
}, - {
- "Name": "F",
- "Accidental": "Natural",
- "PitchClass": 5
}, - {
- "Name": "A",
- "Accidental": "Natural",
- "PitchClass": 9
}
]
}, - {
- "Root": {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}, - {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - {
- "Name": "D",
- "Accidental": "Natural",
- "PitchClass": 2
}
]
}, - {
- "Root": {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - "Type": "Major",
- "Notes": [
- {
- "Name": "C",
- "Accidental": "Natural",
- "PitchClass": 0
}, - {
- "Name": "E",
- "Accidental": "Natural",
- "PitchClass": 4
}, - {
- "Name": "G",
- "Accidental": "Natural",
- "PitchClass": 7
}
]
}
]
}
]
required | Note (object) The root note of the scale (e.g., "C", "D-Sharp", "G-Flat", etc.) |
required | ScaleType (string) The type of scale ("Major", "Minor", or "HarmonicMinor") |
required | Array of objects (Note) The notes of the scale generated from the root and type |
{- "Root": {
- "Name": "G",
- "Accidental": "Sharp",
- "PitchClass": 8
}, - "Type": "HarmonicMinor",
- "Notes": [
- {
- "Name": "G",
- "Accidental": "Sharp",
- "PitchClass": 8
}, - {
- "Name": "A",
- "Accidental": "Sharp",
- "PitchClass": 10
}, - {
- "Name": "B",
- "Accidental": "Natural",
- "PitchClass": 11
}, - {
- "Name": "C",
- "Accidental": "Sharp",
- "PitchClass": 1
}, - {
- "Name": "D",
- "Accidental": "Sharp",
- "PitchClass": 3
}, - {
- "Name": "E",
- "Accidental": "Natural",
- "PitchClass": 4
}, - {
- "Name": "F",
- "Accidental": "DoubleSharp",
- "PitchClass": 7
}, - {
- "Name": "G",
- "Accidental": "Sharp",
- "PitchClass": 8
}
]
}
Types of musical scales
"Major"
required | NoteName (string) The letter name of the note (A-G) |
required | Accidental (string) The accidental of the note ("Sharp", "Flat", "Natural", "DoubleSharp", or "DoubleFlat") |
pitchClass | integer <int32> The pitch class (0-11) of this note (ignoring octave) |
{- "name": "A",
- "accidental": "Natural",
- "pitchClass": 0
}