Spotify playback API returns null item for podcast episodes

Hey everyone! I’m working on a Python script that fetches currently playing content from Spotify. When I call the player endpoint, everything works fine for music tracks - I get all the song details in the item field. But when podcasts are playing, the item field comes back as null every single time.

def fetch_playback_data():
    if time.time() > token_data.expiry_time:
        print("Token expired, getting new one...")
        update_token()

    if not token_data.current_token:
        print("Token refresh failed.")
        return None, None, None, 0, 0

    auth_headers = {"Authorization": f"Bearer {token_data.current_token}"}

    playback_request = requests.get("https://api.spotify.com/v1/me/player", headers=auth_headers)

    try:
        json_data = playback_request.json()
        print("API Response: -------- ", json_data)
    except ValueError:
        print("Response contains no JSON data.")

    if playback_request.status_code == 200:
        player_data = playback_request.json()

        if player_data and player_data['is_playing']:
            content_type = player_data.get('currently_playing_type')
            current_item = player_data.get('item')

            if content_type == 'track' and current_item:
                song_id = current_item['id']
                song_title = current_item['name']
                performer = current_item['artists'][0]['name']
                current_position = player_data['progress_ms']
                total_length = current_item['duration_ms']
                return song_id, song_title, performer, current_position, total_length
            elif content_type == 'episode':
                if current_item and 'id' in current_item:
                    podcast_id = current_item['id']
                else:
                    context_data = player_data.get('context')
                    if context_data and 'uri' in context_data:
                        uri_string = context_data['uri']
                        if 'episode' in uri_string:
                            podcast_id = uri_string.split(':')[-1]
                        else:
                            print("URI doesn't have episode info.")
                            return None, None, None, 0, 0
                    else:
                        print("Missing context data for podcast.")
                        return None, None, None, 0, 0

                episode_request = requests.get(f"https://api.spotify.com/v1/episodes/{podcast_id}", headers=auth_headers)
                if episode_request.status_code == 200:
                    episode_data = episode_request.json()
                    episode_title = episode_data['name']
                    show_creator = episode_data['show']['publisher']
                    current_position = player_data['progress_ms']
                    total_length = episode_data['duration_ms']
                    return podcast_id, episode_title, show_creator, current_position, total_length
                else:
                    print("Episode fetch failed. Error:", episode_request.text)
        else:
            print("Nothing is playing right now.")
    else:
        print("Playback request failed. Error:", playback_request.text)

    return None, None, None, 0, 0

Has anyone found a reliable way to handle this issue? Any suggestions would be awesome!

Yeah, this is a known Spotify quirk - the item field comes back null for podcast episodes since they use different data structures than music tracks. Your fallback with the context URI is spot on.

One thing that helped me: add a short delay after detecting episode playback before hitting the API again. Sometimes the episode data isn’t ready even when the context shows it’s playing.

Also double-check your app has the right scopes for podcast data. user-read-playback-state should cover it, but I’ve seen weird behavior depending on how the token was set up initially.

Your episode endpoint call looks right - just watch out for rate limiting since you’re making two API calls every time you check podcasts.

Same issue here with my Spotify tracker. Podcasts are weird through their API - episodes show up randomly. I added a small timeout between requests and check if currently_playing_type equals ‘episode’ before running fallback logic. Premium and free accounts handle podcast data differently too, so check that if you’re still stuck.

Had this exact problem with Spotify’s API for podcasts a few months ago. The null responses happen because of how they stream and cache data on their end. I fixed it with a simple retry - when you get null, wait a couple seconds and try again. Usually works the second time. Also check the actions field in the response - it might tell you why the item’s missing. I’d suggest caching episode data locally as backup for when the API craps out, and make sure your error handling is solid when parsing context URIs since malformed ones will break things.