Announcements
Happy Values Week! Today we celebrate *Team Work* in the Spotify Stars Program!

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

WebApi Get Currently Playing Track fails with 404 Error

WebApi Get Currently Playing Track fails with 404 Error

hey, I've tried to use https://developer.spotify.com/documentation/web-api/reference/get-the-users-currently-playing-track but I receive the following content:

{
  "error" : {
    "status" : 404,
    "message" : "Invalid username"
  }
}

instead of

{
  "context": {
    "type": "playlist",
    "href": "https://api.spotify.com/v1/playlists/5SfsuZkhPp0MFVbPFshT5L",
    "external_urls": {
      "spotify": "https://open.spotify.com/playlist/5SfsuZkhPp0MFVbPFshT5L"
    },
    "uri": "spotify:playlist:5SfsuZkhPp0MFVbPFshT5L"
  },
  "timestamp": 1744893576278,
  "progress_ms": 136,
  "is_playing": false,
  "item": {
    "album": {
      "album_type": "album",
      "total_tracks": 48,
      "available_markets": [
        "AT",
        "DE"
      ],
      "external_urls": {
        "spotify": "https://open.spotify.com/album/6QrJvzm8ZWxCV5Lje4Cjmw"
      },
      "href": "https://api.spotify.com/v1/albums/6QrJvzm8ZWxCV5Lje4Cjmw",
      "id": "6QrJvzm8ZWxCV5Lje4Cjmw",
      "images": [
        {
          "url": "https://i.scdn.co/image/ab67616d0000b27315e3c3424572a2baa648bad3",
          "height": 640,
          "width": 640
        },
        {
          "url": "https://i.scdn.co/image/ab67616d00001e0215e3c3424572a2baa648bad3",
          "height": 300,
          "width": 300
        },
        {
          "url": "https://i.scdn.co/image/ab67616d0000485115e3c3424572a2baa648bad3",
          "height": 64,
          "width": 64
        }
      ],
      "name": "Welcome to DJ Antoine - Remixed",
      "release_date": "2011-10-28",
      "release_date_precision": "day",
      "type": "album",
      "uri": "spotify:album:6QrJvzm8ZWxCV5Lje4Cjmw",
      "artists": [
        {
          "external_urls": {
            "spotify": "https://open.spotify.com/artist/6yTYR09WCvsgdnurDW4WQo"
          },
          "href": "https://api.spotify.com/v1/artists/6yTYR09WCvsgdnurDW4WQo",
          "id": "6yTYR09WCvsgdnurDW4WQo",
          "name": "DJ Antoine",
          "type": "artist",
          "uri": "spotify:artist:6yTYR09WCvsgdnurDW4WQo"
        }
      ]
    },
    "artists": [
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/6yTYR09WCvsgdnurDW4WQo"
        },
        "href": "https://api.spotify.com/v1/artists/6yTYR09WCvsgdnurDW4WQo",
        "id": "6yTYR09WCvsgdnurDW4WQo",
        "name": "DJ Antoine",
        "type": "artist",
        "uri": "spotify:artist:6yTYR09WCvsgdnurDW4WQo"
      },
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/2vJfU7tjaOVFyh7oZF8L0J"
        },
        "href": "https://api.spotify.com/v1/artists/2vJfU7tjaOVFyh7oZF8L0J",
        "id": "2vJfU7tjaOVFyh7oZF8L0J",
        "name": "The Beatshakers",
        "type": "artist",
        "uri": "spotify:artist:2vJfU7tjaOVFyh7oZF8L0J"
      }
    ],
    "available_markets": [
      "AT",
      "DE"
    ],
    "disc_number": 1,
    "duration_ms": 191090,
    "explicit": false,
    "external_ids": {
      "isrc": "DEN061101853"
    },
    "external_urls": {
      "spotify": "https://open.spotify.com/track/2CbuG4ib5Wg5q8AEhVgll7"
    },
    "href": "https://api.spotify.com/v1/tracks/2CbuG4ib5Wg5q8AEhVgll7",
    "id": "2CbuG4ib5Wg5q8AEhVgll7",
    "name": "Ma Chérie - DJ Antoine Vs Mad Mark 2K12 Radio Edit",
    "popularity": 49,
    "preview_url": null,
    "track_number": 1,
    "type": "track",
    "uri": "spotify:track:2CbuG4ib5Wg5q8AEhVgll7",
    "is_local": false
  },
  "currently_playing_type": "track",
  "actions": {
    "disallows": {
      "pausing": true
    }
  }
}

any idea how it could work?

Reply
10 Replies

betterdayshier_0-1744897848013.png

now when I click the "Try it" button

Hi @betterdayshier 

Are you playing something from the same Spotify account at same time when you hit the Try it button?

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

yes the posted example result is right

 

sorry for double post I can't find the post edit function

I just wanted to say:

It isn't a premium account but in docs I didn't read anything about premium account requirement for web api (only playback api)
And I use PC Windows 11 spotify client from https://open.spotify.com/download (not the windows store version

if thats important

Hi again @betterdayshier 

Thank you for this information.

You are right it is not in the documentation that Premium is required, but I think this is the reason why it does not work.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

first time I also thought it could be work with an other acc. but my question is, why since I've created this thread the sample don't work anymore. And the next problem was retrieving the playlists from that account which was working with docs sample but with Postman not.

I've tried with web api SDK from github:(spotify/spotify-web-api-ts-sdk) that reproduce the same error

Endpoints that change or access account data like playlists require user authorization. You can read more about it at this page.

One heads-up: if an endpoint requires authorization, the needed scopes are at the top of the API reference page.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

@Ximzend i thought maybe it's going to work with CLIENT_ID and oauth spotify login form and not as I've tried with CLIENT_ID and CLIENT_SECRET methode. I can test this later or so on but no idea about the advantage...from the perspective of the development team

That method is called Client Credentials. You have to get an Access Token using an Authorisation Code Flow.

You cannot access personal data from a user that is not logged in obviously.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Also, you should read this page about Quota Modes.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts