A small FastAPI app that manages composers and pieces.
Returns a list of composers
Example:
[
{
"name": "Sergei Rachmaninoff",
"composer_id": 1,
"home_country": "Russia"
},
{
"name": "Franz Liszt",
"composer_id": 2,
"home_country": "Hungary"
}
]
Returns a list of pieces
- Query Parameters:
composer_id
(int) - An optional ID of the composer to filter on
Example:
[
{
"name": "Etude Tableaux Op. 39 No. 6",
"alt_name": "Little Red Riding Hood",
"difficulty": 9,
"composer_id": 1
},
{
"name": "Waltz Op. 18 No. 1 in E-Flat Major",
"alt_name": "Grande valse brillante",
"difficulty": 4,
"composer_id": 4
}
]
Creates a new composer
-
Body:
name
(string) - Name of the composercomposer_id
(int) - ID of the composer (consider making this auto incrementing so the user doesn't have to pass it in). Raise an HTTP 400 if a duplicate ID is passed in.home_country
(string) - Country the composer was born in
Example body:
{
"name": "Sergei Rachmaninoff",
"composer_id": 1,
"home_country": "Russia"
}
Creates a new piece
- Body:
name
(string) - Name of the piecealt_name
(string) - Optional alternate name of the piecedifficulty
(int) - Difficulty rating of the piece (1-10) (consider restricting the difficulty input to only accept 1-10)composer_id
(int) - ID of the composer. Raise HTTP 400 exception if the composer ID doesn't exist.
Example body:
{
"name": "Etude Tableaux Op. 39 No. 6",
"alt_name": "Little Red Riding Hood",
"difficulty": 9,
"composer_id": 1
}
Updates a composer if they exist, otherwise they are created
-
Path parameters:
composer_id
(int) - ID of the composer
-
Body:
name
(string) - Name of the composercomposer_id
(int) - ID of the composer (consider making this auto incrementing so the user doesn't have to pass it in). Raise an HTTP 400 if a duplicate ID is passed in.home_country
(string) - Country the composer was born in
Example body:
{
"name": "Sergei Rachmaninoff",
"composer_id": 1,
"home_country": "Russia"
}
Updates a piece if it exists, otherwise it is created
-
Path parameters:
piece_name
(string) - Name of the piece
-
Body:
name
(string) - Name of the piecealt_name
(string) - Optional alternate name of the piecedifficulty
(int) - Difficulty rating of the piece (1-10) (consider restricting the difficulty input to only accept 1-10)composer_id
(int) - ID of the composer. Raise HTTP 400 exception if the composer ID doesn't exist.
Example body:
{
"name": "Etude Tableaux Op. 39 No. 6",
"alt_name": "Little Red Riding Hood",
"difficulty": 9,
"composer_id": 1
}
Deletes a composer
- Path parameters:
composer_id
(int) - ID of the composer
Deletes a piece
- Path parameters:
piece_name
(string) - Name of the piece