Routes

Routes to interact with and make changes to the Broadway songs table.

HTTP method Endpoint Function
GET /songs List all songs
GET /songs/{song-id} View a specific song
POST /songs Add a new song
PUT /songs/{song-id} Update the fields of a specific song
DELETE /songs/{song-id} Delete a specific song

Sample Requests

Get, create, update, or delete a song with their associated HTTP methods.

Sample list all songs request

Here is the request to list all songs in JSON format:

GET http://localhost:8888/songs

Sample Response

[
  {
    "id": 1,
    "title": "Helpless",
    "composer": "Lin-Manuel Miranda",
    "artist": "Phillipa Soo",
    "musical": "Hamilton",
    "duration": "3:21",
    "trackNumber": 6,
    "created_at": "2017-04-04 21:31:50",
    "updated_at": "2017-04-04 21:31:50"
  },
  {
    "id": 2,
    "title": "Seize the Day",
    "composer": "Alan Menken",
    "artist": "Jeremy Jordan",
    "musical": "Newsies",
    "duration": "5:09",
    "trackNumber": 10,
    "created_at": "2017-04-06 21:58:10",
    "updated_at": "2017-04-06 21:58:10"
  }
]

Sample view specific song request

Here is a sample request to view a specific song with ID 2:

GET http://localhost:8888/songs/2

Sample Response

{
    "id": 2,
    "title": "Seize the Day",
    "composer": "Alan Menken",
    "artist": "Jeremy Jordan",
    "musical": "Newsies",
    "duration": "5:09",
    "trackNumber": 10,
    "created_at": "2017-04-06 21:58:10",
    "updated_at": "2017-04-06 21:58:10"
}

Sample create song request

Here is a sample create song request:

POST http://localhost:8888/songs
    parameter name: title
        value: Helpless
    parameter name: composer
        value: Lin-Manuel Miranda
    parameter name: artist
        value: Phillipa Soo
    parameter name: musical
        value: Hamilton
    parameter name: duration
        value: 4:10
    parameter name: trackNumber
        value: 10

The above POST request would create a new song in the database with the specified parameters.

Parameter Descriptions
  • title - the title of the song
  • composer - the composer of the song
  • artist - the person who sings the song
  • musical - the musical the song is from
  • duration - the duration of the song
  • trackNumber - the track number of the song

Sample Response

{
    "song created": true
}

Sample update song request

Here is a sample update song request:

PUT http://localhost:8888/songs/1
    parameter name: duration
        value: 4:21
    parameter name: trackNumber
        value: 9

The above PUT request would update the 'duration' and 'trackNumber' fields of the song with ID 1.

Sample Response

{
    "song updated": true
}

Sample delete song request

Here is a sample delete song request:

DELETE http://localhost:8888/songs/1

The above DELETE request would delete the song with ID 1.

Sample Response

{
    "song deleted": true
}

results matching ""

    No results matching ""