Repository navigation
3. APIs
Returns 25 song recommendations based on the user's music attribute vector.
- 10 songs are completely attribute-based and do not account for genre
- 10 songs use both attributes and the user's favorite genres
- 5 songs use both attributes and the user's favorite artists
Returns top 25 songs in the United States if there is no logged-in user or if the user has not yet created a post.
Endpoint: GET /recommendations/
Request Parameters
| Key | Location | Type | Description |
|---|---|---|---|
username |
Session Cookie | String | Current User |
Response Codes
| Code | Description |
|---|---|
200 OK |
Success |
400 Bad Request |
Invalid parameters |
Returns
If no user is logged in or no posts created by user
| Key | Location | Type | Description |
|---|---|---|---|
popular_songs |
JSON | List of Spotify Track IDs | Top 25 songs on Spotify in the United States |
For logged-in users with 1 or more posts created
| Key | Location | Type | Description |
|---|---|---|---|
attribute_recommendations |
JSON | List of Spotify Track IDs | Attribute-based recommendations (random genres) |
genre_recommendations |
JSON | List of Spotify Track IDs | Attribute and genre-based recommendations based on user's favorite genres |
artist_recommendations |
JSON | List of Spotify Track ID | Attribute and artist-based recommendations based on user's favorite artists |
attribute_error |
JSON | Dictionary | contains the average error % for each attribute between recommendation and the user's attribute vector. |
Example
curl -b cookies.txt -c cookies.txt -X GET https://OUR_SERVER/recommendations/'
{
"attribute_error": {
"acousticness": 0.1342,
"danceability": 0.2567,
"energy": 0.1144,
"instrumentalness": 0.021,
"liveness": 0.0324,
"loudness": 0.0084,
"speechiness": 0.0528,
"tempo": 0.0446,
"valence": 0.1538
},
"attribute_recommendations": [
"spotify:track:3joo84oco9CD4dBsKNWRRW",
"spotify:track:5DxlyLbSTkkKjJPGCoMo1O",
...
],
"genre_recommendations": [
"spotify:track:4MzXwWMhyBbmu6hOcLVD49",
"spotify:track:0bYg9bo50gSsH3LtXe2SQn",
...
],
"artist_recommendations": [
"spotify:track:2EjXfH91m7f8HiJN1yQg97",
"spotify:track:5o8EvVZzvB7oTvxeFB55UJ",
...
],
"url": "/recommendations/"
}
Our front end is developed in Kotlin with Android Studio IDE and we will be using Spotify's Web API.
We use Spotify's Web API on the front end for numerous purposes that provide the core functionality of the app. The Spotify API is called to get information about the user-seeded song, and then it is used to get information (ie. BPM/key) to determine which songs to recommend. Lastly, the API is used again to save the recommendations to a playlist in the users account.
Spotify's Web API requires authorization before we make any requests. We will be following Client Credentials Flow.
When a song is displayed in our app, we show the name of the song, the name of the song's artist, the title of the album containing the song, and the image (album cover) for that album. For this, we use Spotify's Get a Track endpoint.
When a user wants to make a post in our app, they are prompted to select a song to include in the post. We use Spotify's Search endpoint to let the user search for a song.