Skip to content

API document

Alice Li edited this page Jul 25, 2022 · 4 revisions

SonicCloud 🎶🌩️

sample user:

  • id : 3
  • username : Riri
  • firstName : Rihanna
  • lastName : Fanta
  • email : riri@user.io
  • password : password3

API Documentation

All endpoints that require authentication

All endpoints that require a current user to be logged in.

  • Request: endpoints that require authentication
  • Error Response: Require authentication
    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Authentication required",
        "statusCode": 401
      }

All endpoints that require proper authorization

All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).

  • Request: endpoints that require proper authorization
  • Error Response: Require proper authorization
    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Forbidden",
        "statusCode": 403
      }

Get the Current User

Returns the information about the current user that is logged in.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: '/api/session'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "user": {
          "id": 3,
          "username": "Riri",
          "firstName": "Rihanna",
          "lastName": "Fanta",
          "email": "riri@user.io"
               }
      }

Log In a User

Logs in a current user with valid credentials and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: '/api/session'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "credential": "Riri",
        "password": "password3"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "user": {
              "id": 3, 
              "username": "Riri",
              "firstName": "Rihanna",
              "lastName": "Fanta",
              "email": "riri@user.io",
              "createdAt": "2022-07-06T21:20:53.336Z",
              "updatedAt": "2022-07-06T21:20:53.336Z"
          }
      }
  • Error Response: Invalid credentials

    • Status Code: 401

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Invalid credentials",
        "statusCode": 401
      }
  • Error response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation error",
        "statusCode": 400,
        "errors": {
          "email": "Email is required",
          "password": "Password is required"
        }
      }

Sign Up a User

Creates a new user, logs them in as the current user, and returns the current user's information.

  • Require Authentication: false

  • Request

    • Method: POST

    • URL: '/api/users/signup'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "username": "ladygaga9",
        "firstName": "Lady",
        "lastName": "Gaga",
        "email": "gaga9@user.io",
        "password": "password9"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 5,
        "firstName": "Lady",
        "lastName": "Gaga",
        "username": "ladygaga9",
        "email": "gaga9@user.io",
        "token": ""
      }
  • Error response: User already exists with the specified email

    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "statusCode": 403,
        "errors": {
          "email": "User with that email already exists"
        }
      }
  • Error response: User already exists with the specified username

    • Status Code: 403

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "User already exists",
        "statusCode": 403,
        "errors": {
          "username": "User with that username already exists"
        }
      }
  • Error response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation error",
        "statusCode": 400,
        "errors": {
          "email": "Invalid email",
          "username": "Username is required",
          "firstName": "First Name is required",
          "lastName": "Last Name is required"
        }
      }

Get all Songs

Returns all the songs.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/songs/all'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Songs":[
          {
            "id": 1,
            "userId": 1,
            "albumId": 1,
            "title": "Yesterday",
            "description": "A song about the past.",
            "url": "audio url",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }

Get all Songs created by the Current User

Returns all the songs created by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: '/songs/mysongs'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Songs": [
          {
            "id": 1,
            "userId": 1,
            "albumId": 1,
            "title": "Yesterday",
            "description": "A song about the past.",
            "url": "audio url",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }

Get details of a Song from an id

Returns the details of a song specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/songs/:songId(\d+)'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "albumId": 1,
        "title": "Yesterday",
        "description": "A song about the past.",
        "url": "audio url",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-19 20:39:36",
        "previewImage": "image url",
        "Artist": {
          "id": 1,
          "username": "JohnSmith",
          "previewImage": "image url"
        },
        "Album": {
          "id": 1,
          "title": "Time",
          "previewImage": "image url"
        }
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Create a Song for an Album based on the Album's id

Creates and returns a new song.

  • Require Authentication: true

  • Require proper authorization: Album must belong to the current user

  • Request

    • Method: POST

    • URL: '/albums/:albumId'

    • you may use '/albums/2'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "title": "Yesterday",
        "description": "A song about the past.",
        "url": "audio url",
        "imageUrl": "image url"
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "albumId": 1,
        "title": "Yesterday",
        "description": "A song about the past.",
        "url": "audio url",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-19 20:39:36", 
        "previewImage": "image url"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "title": "Song title is required",
          "url": "Audio is required"
        }
      }
  • Error response: Couldn't find an Album with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Album couldn't be found",
        "statusCode": 404
      }

Edit a Song

Updates and returns an existing song.

  • Require Authentication: true

  • Require proper authorization: Song must belong to the current user

  • Request

    • Method: PUT

    • URL: '/songs/mysongs'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
      "id":1,
      "title":"love the way you hike",
      "description":"2022 version of Love The Way You Lie",
      "url":"www.love.the.way.you.hike",
      "previewImage":"youhiking.jpg"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
      "id": 1,
      "userId": 3,
      "albumId": 2,
      "title": "love the way you hike",
      "description": "2022 version of Love The Way You Lie",
      "url": "www.love.the.way.you.hike",
      "previewImage": "youhiking.jpg"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "title": "Song title is required",
          "url": "Audio is required"
        }
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Delete a Song

Deletes an existing song.

  • Require Authentication: true

  • Require proper authorization: Song must belong to the current user

  • Request

    • Method: DELETE
    • URL: '/songs/mysongs'
    • Body: { "id":1 }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted",
        "statusCode": 200 
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Get all Albums

Returns all the Albums.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/albums'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Albums": [
          {
            "id": 1,
            "userId": 1,
            "title": "Time",
            "description": "An album about time.",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }

Get all Albums created by the Current User

Returns all the Albums created by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: '/albums/myalbums'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Albums":[
          {
            "id": 1,
            "userId": 1,
            "title": "Time",
            "description": "An album about time.",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }

Get details of an Album from an id

Returns the details of an album specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/albums/:albumId(\d+)'
    • try: /albums/1
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 1,
        "userId": 1,
        "title": "Time",
        "description": "An album about time.",
        "createdAt": "2021-11-19 20:39:36",
        "updatedAt": "2021-11-19 20:39:36",
        "previewImage": "image url",
        "Artist": {
          "id": 1,
          "username": "JohnSmith",
          "previewImage": "image url"
        },
        "Songs": [
          {
            "id": 1,
            "userId": 1,
            "albumId": 1,
            "title": "Yesterday",
            "description": "A song about the past.",
            "url": "audio url",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }
  • Error response: Couldn't find an Album with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Album couldn't be found",
        "statusCode": 404
      }

Create an Album

Creates and returns a new album.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: '/albums/myalbums'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "name": "Time",
        "previewImage": "image url"
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 4,
        "name": "Time",
        "userId": 3,
        "previewImage": "image url",
        "updatedAt": "2022-07-08T21:40:53.989Z",
        "createdAt": "2022-07-08T21:40:53.989Z"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "title": "Album title is required"
        }
      }

Edit an Album

Updates and returns an existing album.

  • Require Authentication: true

  • Require proper authorization: Album must belong to the current user

  • Request

    • Method: PUT/PATCH

    • URL: '/albums/myalbums'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 2,
        "name": "Good Girl Gone Good",
        "previewImage": "image url"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "thealbum": {
          "id": 2,
          "name": "Good Girl Gone Good",
          "userId": 3,
          "previewImage": "image url",
          "updatedAt": "2022-07-08T21:44:05.594Z"
      }
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "title": "Album title is required"
        }
      }
  • Error response: Couldn't find an Album with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Album couldn't be found",
        "statusCode": 404
      }

Delete an Album

Deletes an existing album.

  • Require Authentication: true

  • Require proper authorization: Album must belong to the current user

  • Request

    • Method: DELETE
    • URL: '/myalbums'
    • Body: { "id":11 }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted",
        "statusCode": 200 
      }
  • Error response: Couldn't find an Album with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Album couldn't be found",
        "statusCode": 404
      }

Get all Comments by a Song's id

Returns all the comments that belong to a song specified by id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/songs/:songId/comments'
    • try: /songs/2/comments
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
         {
          "id": 1,
          "userId": 1,
          "songId": 2,
          "body": "we should collab again"
      },
      {
          "id": 3,
          "userId": 4,
          "songId": 2,
          "body": "all time fav, 10/10"
      }
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Create a Comment for a Song based on the Song's id

Create and return a new comment for a song specified by id.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: '/songs/:songId/comments'

    • try: /songs/3/comments

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "body": "I love this song!"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
      "id": 6,
      "userId": 3,
      "songId": 3,
      "body": "I love this song!",
      "updatedAt": "2022-07-08T21:47:41.110Z",
      "createdAt": "2022-07-08T21:47:41.110Z"
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation error",
        "statusCode": 400,
        "errors": {
          "body": "Comment body text is required"
        }
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Edit a Comment

Update and return an existing comment.

  • Require Authentication: true

  • Require proper authorization: Comment must belong to the current user

  • Request

    • Method: PUT/PATCH

    • URL: '/comments/mycomments'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 4,
        "body": "H to the izz-O"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 4,
        "userId": 3,
        "songId": 3,
        "body": "H to the izz-O",
        "updatedAt": "2022-07-08T21:50:59.184Z"
      }
  • Error Response: Body validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation error",
        "statusCode": 400,
        "errors": {
          "body": "Comment body text is required",
        }
      }
  • Error response: Couldn't find a Comment with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Comment couldn't be found",
        "statusCode": 404
      }

Delete a Comment

Delete an existing comment.

  • Require Authentication: true

  • Require proper authorization: Comment must belong to the current user

  • Request

    • Method: DELETE
    • URL: 'comments/mycomments'
    • Body: { "id":4 }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted",
        "statusCode": 200 
      }
  • Error response: Couldn't find a Comment with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Comment couldn't be found",
        "statusCode": 404
      }

Get details of an Artist from an id

Returns the details of an artist specified by their id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/users/artists/:artistId'
    • try: /users/artists/1
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
          "id": 1,
          "username": "kermitZ",
          "firstName": "Kermit",
          "lastName": "JayZ",
          "Albums": [
          ...
                  ],
          "Songs": [
          ...
                  ],
          "Playlists": [
          ...
          ]
      }
  • Error response: Couldn't find an Artists with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Artist couldn't be found",
        "statusCode": 404
      }

Get all Songs of an Artist from an id

Returns all the songs created by the specified artist.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/users/artist/:artistId/songs'
    • try: /users/artists/1/songs
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {

[ { "id": 3, "userId": 1, "albumId": 1, "title": "Empire State of Mind", "description": "...", "url": "www.empire.state.of.mind", "previewImage":... }, { "id": 4, "userId": 1, "albumId": 1, "title": "Izzo (H.O.V.A.)", "description": "...", "url": "www.encore.song", "previewImage": "..." } ] } ```

  • Error response: Couldn't find an Artist with the specified id
    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Artist couldn't be found",
        "statusCode": 404
      }

Get all Albums of an Artist from an id

Returns all the albums created by the specified artist.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/users/artist/:artistId/albums'
    • try: /users/artists/1/albums
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        {
            "id": 1,
            "name": "The Hits Collection, Volume One",
            "userId": 1,
            "previewImage": "..."
        }
      }
  • Error response: Couldn't find an Artist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Artist couldn't be found",
        "statusCode": 404
      }

Get all Playlists of an Artist from an id

Returns all the playlists created by the specified artist.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/users/artist/:artistId/playlists'
    • try: /users/artists/1/playlists
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        {
            "id": 5,
            "name": "Z100-1",
            "userId": 1,
            "previewImage": "55555555.jpg"
        },
        {
            "id": 6,
            "name": "Z100-2",
            "userId": 1,
            "previewImage": "66666666.jpg"
        }
      }
  • Error response: Couldn't find an Artist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Artist couldn't be found",
        "statusCode": 404
      }

Create a Playlist

Creates and returns a new playlist.

  • Require Authentication: true

  • Request

    • Method: POST

    • URL: '/playlists'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "name": "Current Favorites",
        "previewImage": "image url"
      }
  • Successful Response

    • Status Code: 201

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "newPlaylist": {
            "id": 7,
            "name": "Current Favorites",
            "userId": 3,
            "previewImage": "image url",
            "updatedAt": "2022-07-08T21:59:59.070Z",
            "createdAt": "2022-07-08T21:59:59.070Z"
        }
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "name": "Playlist name is required"
        }
      }

Add a Song to a Playlist based on the Playlists's id

Add a song to a playlist specified by the playlist's id.

  • Require Authentication: true

  • Require proper authorization: Playlist must belong to the current user

  • Request

    • Method: POST

    • URL: '/playlists/myplaylists'

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "playlistId":1,
        "songId": 2
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "songId": 2,
        "playlistId": 1,
        "updatedAt": "2022-07-08T22:13:21.289Z",
        "createdAt": "2022-07-08T22:13:21.289Z"
      }
  • Error response: Couldn't find a Playlist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Playlist couldn't be found",
        "statusCode": 404
      }
  • Error response: Couldn't find a Song with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Song couldn't be found",
        "statusCode": 404
      }

Get details of a Playlist from an id

Returns the details of a playlist specified by its id.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/playlists/:playlistId(\d+)'
    • try: /playlists/1
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
         "id": 1,
        "name": "Riri's playlist NO.1",
        "userId": 3,
        "previewImage": "111111111.jpg"
      }
  • Error response: Couldn't find a Playlist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Playlist couldn't be found",
        "statusCode": 404
      }

Edit a Playlist

Updates and returns an existing playlist.

  • Require Authentication: true

  • Require proper authorization: Playlist must belong to the current user

  • Request

    • Method: PUT/PATCH

    • URL: '/playlists/myplaylists'

    • Headers:

      • Content-Type: application/json
    • Body:

       {
           "id":2,
            "name": "Riri's playlist NO.5",
            "previewImage": "image url"
      }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "id": 2,
        "name": "Riri's playlist NO.5",
        "userId": 3,
        "previewImage": "image url",
        "updatedAt": "2022-07-08T22:21:37.155Z"
      }
  • Error Response: Body validation error

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "name": "Playlist name is required"
        }
      }
  • Error response: Couldn't find a Playlist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Playlist couldn't be found",
        "statusCode": 404
      }

Delete a Playlist

Deletes an existing playlist.

  • Require Authentication: true

  • Require proper authorization: Playlist must belong to the current user

  • Request

    • Method: DELETE
    • URL: '/playlists/myplaylists'
    • Body:
         {
           "id":1
         }
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Successfully deleted",
        "statusCode": 200 
      }
  • Error response: Couldn't find a Playlist with the specified id

    • Status Code: 404

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Playlist couldn't be found",
        "statusCode": 404
      }

Get all Playlists created by the Current User

Returns all the playlists created by the current user.

  • Require Authentication: true

  • Request

    • Method: GET
    • URL: '/playlists/myplaylists'
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Playlists":[
          {
            "id": 1,
            "userId": 1,
            "name": "Current Favorites",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ]
      }

Add Query Filters to Get All Songs

Return songs filtered by query parameters.

  • Require Authentication: false

  • Request

    • Method: GET
    • URL: '/songs'
    • Query Parameters
      • page: integer, minimum: 0, maximum: 10, default: 0
      • size: integer, minimum: 0, maximum: 20, default: 20
      • title: string, optional
      • createdAt: string, optional
    • Body: none
  • Successful Response

    • Status Code: 200

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "Songs":[
          {
            "id": 1,
            "userId": 1,
            "albumId": 1,
            "title": "Yesterday",
            "description": "A song about the past.",
            "url": "audio url",
            "createdAt": "2021-11-19 20:39:36",
            "updatedAt": "2021-11-19 20:39:36",
            "previewImage": "image url"
          }
        ],
        "page": 2,
        "size": 25
      }
  • Error Response: Query parameter validation errors

    • Status Code: 400

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "message": "Validation Error",
        "statusCode": 400,
        "errors": {
          "page": "Page must be greater than or equal to 0",
          "size": "Size must be greater than or equal to 0",
          "createdAt": "CreatedAt is invalid"
        }
      }