Create app-bound playlist on Spotify - spotify

Is it possible to create an app-bound playlist?
It's possible to create a playlist for a user, but how will I know which one that is when they move away from my app?
Ideally, I would only need to be able to create/edit 1 playlist.
Edit: Have found this http://developer.spotify.com/technologies/apps/guidelines/integration/#appsthatcreateplaylisturi:s
But if anyone has great ideas, I'm still open!

As you've found out yourself, you can't create a playlist in a user's library that's somehow linked to your application using the Spotify Apps API.
I thought it'd be a good idea to also quote the relevant part of the Integration Guidelines that you've linked to:
If you want to generate and save the user’s personal playlists in the
app, you should not keep playlist information only saved within the
app. Playlist information should instead be handled by utilizing user
playlists, so that the user can access playlists as usual. They
shouldn’t have to go to the app to access a certain playlist that they
have created.
Suggestion:
I think there's several ways to do what you want to do though.
One way could be to let a user create a new playlist using your application and save it to the user's library, and at the same time save the playlist URI to your own back end. As you've noted, playlist URIs are obfuscated (e.g. they look like spotify:user:#:playlist:783BHaT7Xb8K5VyYstxsj3 instead of spotify:user:thelinmichael:playlist:783BHaT7Xb8K5VyYstxsj3, the username is replaced by # for the currently logged in user, and #xxx.. for other users). You could still save the last part of the URI, which I believe is unique for every playlist. Using a hashmap to map that part of the playlist URI to properties you want to keep track of would let you do quick lookups of a user's playlists to see if they are associated to your app. You could iterate though the user's library to gather all obfuscated URIs, and send them to your backend in a single HTTP request. The response from your server could be the index of the library playlists that matched the playlist on your backend, along with the properties you've mapped to it. Again, this was just a suggestion and possibly not the best way forward but I hope it gave you some ideas. :-)

Related

Spotify remove a track from a playlist not owned by the user

As you might know, the permission system from Spotify isn't the best. You can just mark a playlist collaborative, and every single spotify user can edit the Playlist without my approval. Therefore, I am writing an application (using Spotify Web Api, node and mysql) that gives the user more control over the collaborative playlists. It should support sub-playlists, votes and a small permission system, which allows just some users to modify the playlist.
In order for that to work, I need a service running all the time in the background. This service should sync my version of the playlist with spotify. Because the user, who owns the playlist, will most likely not be logged in, i have created a special Spotify User for my service. Now, i have to edit the collaborative Playlist using this spotify user.
When i try to delete some Tracks from such a playlist, i get the following answer:
{
"error" :
{
"status" : 403,
"message" : "You cannot remove tracks from a playlist you don't own."
}
}
Do you know if there is a way to delete a Track from a playlist i don't own? And if not, Do you have any idea how to get around this problem?
Do you know if there is a way to delete a Track from a playlist i don't own?
This isn't possible, even if the playlist is collaborative.
And if not, Do you have any idea how to get around this problem?
One way is to create a playlist owned and edited by a user that you control. Server-side you'd keep an access token for that user, and simply refresh it when necessary. Since the refresh token lasts forever, you'd never have to require a user to go through any form of authentication flow.
Hope this helped!

How to share app id with an extension?

Is there a way to programmatically find app's id based on a name or some other criteria?
I have an extension that needs to exchange some data with an app. However, in order to send a message to the app I need to know the app's id. How can I get the id without any end user involvement?
I think I could hard-code the app's id into the extension but I'm not sure if this is the best option. In order to do that, I would always have to publish the app first, find its id, hard-code it into the extension, and then publish the extension.
Would this work? Are there better options to accomplish the above?
Thanks.
There is a way, but it's too heavy to be justified in a regular extension: chrome.management API. To be able to find out your app's ID with it, you'd have to make sure that the app be already installed by the user before the extension makes a query. In addition, such a permission may be hard to slip by more savvy users.
Hardcoding is your best option. The good news is, your app's ID will be fixed after the initial upload and will never change with subsequent uploads.

Is there any way to get an artist's user id with the Spotify API?

One of the cool things about Spotify is the ability to view playlists created by both users and artists.
You can get a list of playlists for any user with:
https://api.spotify.com/v1/users/{user_id}/playlists
This will work if you plug in an artist's user id as well.
Example: https://api.spotify.com/v1/users/officialfoofighters/playlists returns playlists created by Foo Fighters (the actual band).
The problem is that I see no way to programmatically get an artist's user id. The actual artist id is different and will not work. I managed to manually get Foo Fighter's user id in a hacky way using the Spotify desktop client, but I would like to find a programmatic solution.
Anyone know of any workarounds?
I'm happy that you're asking for this, because it's a feature that we've been wanting to add to the Web API for a while. So even though the answer to this question is that it isn't possible to find an artist's username using the Web API (and the other way around) right now, I'd urge you to keep up to date on changes in the API through #SpotifyPlatform or our Change Log.

How to grab user track info through spotify api

I recently just got through the beginning tutorial for creating a web app with the spotify api. https://developer.spotify.com/web-api/tutorial/. The tutorial was great for showing how to authenticate a user with oauth and log in a user.
The problem I am having is with the endpoint. I can't seem to figure out how to change the endpoint so that instead of displaying a users profile, I can see a list of a users track, better yet starred or top 10 tracks.
for a 10,000 view perspective of what I want to build is a app that would allow users to easily log in through their spotify account, take their stared or top tracks and push them to a radio that I am building with an raspberry pi.
I am new to working with the spotify api and working with api's in general so whatever advice would be awesome.
At the moment, there is no way to get the "starred"-playlist. (At least it's not documented)
I don't know what you mean with "Top 10 User tracks", since this doesn't exist as far as I know
To get a list of the account's current playlists, change the URL to:
https://api.spotify.com/v1/users/{user_id}/playlists
With this URL, you will get a list of simple-playlist-objects wrapped inside a paging-object. Now you can select one of the playlists (or loop through them) and fetch its track this way
NOTE:
If you also want to fetch private playlists, make sure you use the scope playlist_read_private

Share button for a new playlist

How can I show a share popup for a playlist I created by like this?
var playlist = new models.Playlist("My cool playlist");
As the uri is not available for the new playlist due to security policies, how can I allow the user to share the playlist though the standard share popup? The showSharePopup does not accept an instance of playlist but without any URI I don't know how to do?
The reason for asking is that I'm working on an app for distribution on App FInder and they want me to make it possible to share new playlists from the app in the next update.
...and they want me to make it possible to share new playlists from the app in the next update.
If you have someone in Spotify asking you to do something that seems impossible, it's probably a good idea to ask them how they want you to do it!

Resources