Announcements

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

How can I retrieve all playlists containing a specific song for a given user using the Spotify API?

How can I retrieve all playlists containing a specific song for a given user using the Spotify API?

Plan

Premium


Country

Germany

 

Device

Microsoft Windows Laptop

Operating System

Win 11

 

My Question or Issue

Here is an example of the output I'm trying to achieve. User A has the following songs and playlists:


Songs: A, B, C
Playlists:

  • Playlist 1: Song A, Song B
  • Playlist 2: Song B, Song C

Desired Output (Playlists should be listed in alphabetical order):

  • Song A: Playlist 1
  • Song B: Playlist 1, Playlist 2
  • Song C: Playlist 2

Is there a way to query this information using the Spotify API? If yes, which endpoints or methods would be most effective?

Reply
1 Reply

I believe you'll have to do it in the inverse of the way you're thinking.

1. Get all of a user's playlists
 You'll have to paginate through the list of playlists if there are more than 50. You'll want to keep track of things like the playlist ID, but specifically the number of tracks.
2. For each playlist, get items in that playlist until you've either found the song or you've reached the end of the playlist.

Unfortunately there's no endpoint to do directly what you're looking for.

 

 

Suggested posts