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

Using SPOTIPY to search for songs (tempo, key..) in Django (Is it Possible ?)

Solved!

Using SPOTIPY to search for songs (tempo, key..) in Django (Is it Possible ?)

Plan

Free

 

Country

Sweden

 

Code

Django, Bootstrap, PresSQL

 

IDE

Code anywhere 

 

Operating System

Windows 10

 

My Question or Issue

 

So I am trying to use Spotipy in my school Django project. I´ve read in Django docs that external APIs is not always supported. Before I even begin troubleshooting this does anyone Know if this is doable / or have you tried this yourself  ?

 

So I am pretty new at coding but, 

my plan is to let users come to my site and search with the Spotipy API to find songs with a specific tempo, key, location, language. I have installed URL, client ID and secret key in a virtual environment env.py as I don´t want the API key to be visible.

 

I have prior done extensive reading in spotify dev docs to research this and I know saw you can search for lots of characteristics in songs, key, tempo, location, popularity, liveness and many more.

 

And if you know of any similar Github Django repos that use the spotipy API, please link to these 🤗

 

Reply

Accepted Solutions
Marked as solution

Edit: The endpoint described in this reply is deprecated. More information on this page.

 

You can use the Get Recommendations endpoint: https://developer.spotify.com/documentation/web-api/reference/get-recommendations

How to use it with Spotipy, you can read here: https://spotipy.readthedocs.io/en/latest/#spotipy.client.Spotify.recommendations

Note: there isn't an endpoint you can use to search with location or language.

 

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.

View solution in original post

5 Replies
Marked as solution

Edit: The endpoint described in this reply is deprecated. More information on this page.

 

You can use the Get Recommendations endpoint: https://developer.spotify.com/documentation/web-api/reference/get-recommendations

How to use it with Spotipy, you can read here: https://spotipy.readthedocs.io/en/latest/#spotipy.client.Spotify.recommendations

Note: there isn't an endpoint you can use to search with location or language.

 

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.

Thank you very much, seems like simpler solution than the one I was investigating, which mostly is a good thing. Have you some example where this is written in a repo, as a newb I need to know what goes where 😂

Spotipy supports different Cache Handlers. I've found a Django Session Cache Handler in the code, linking to https://docs.djangoproject.com/en/3.2/topics/http/sessions/

Sadly, I have no knowledge of Django.

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.

This is the end result, its not pretty and need some work still. https://bangrad.herokuapp.com/  created a django app with spotify search functionality. You have to log in with your spotify account to use the search function. Would be great to find another solution to having to refresh this access. 

I read your post again and I see I made a mistake. You don't need to use the Authorization Code flow to use search functionally. In your case, you could just use Client Credential.

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

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random