52 points · by garethr · 15y ago · 28 comments
Other APIs may be imperfect implementations of the ideal, but Rdio's made no attempt to look anything like REST. The complaint wasn't about adhering to a spec, but simply inaccurate nomenclature.
Hi Ian, if it's not too much trouble could you give an example of functionality that didn't work well with REST?
* search
* deleting songs from a playlist (safely)
* multidimentional stats queries (eg: http://developer.rdio.com/docs/read/rest/Methods#getHeavyRot...)
Perhaps we could have modelled these in a REST-like manner, but it seemed simpler to make the functionality available through an RPC protocol - simpler for us to implement and simpler for developers to integrate into their software.
Query parameters are appropriate here because they're not being used to specify which collection resource to retrieve. They're being used to alter the representation of the collection. This is just like using start and count query parameters to allow paging through a large collection.
For your search, you would use a single query parameter, and for getHeavyRotation you would use one parameter for each field you can filter on. They'd be optional of course, and if none are specified you get the whole collection.
Regarding deleting songs "safely", I'm not sure what you mean but I'm guessing you want some confirmation or recovery. I assume each song has a playlist attribute; instead of allowing a DELETE method on the song I would have a trashbin playlist, and allow the song resource to be updated with the playlist attribute changed to the trashbin uri. That allows the songs to be recovered if they are moved by mistake. To really clear it out, you could allow DELETE on /{trashbin uri}/{song id}. Eg: the song resource can only be deleted via the trashbin.
As far as deleting songs "safely", what Ian means is that for any given playlist (of which a user has an unlimited number) any given song can be in it any number of times. So when you delete a song, we generally ask for song_id and index to make sure that a) the playlist hasn't mutated (much), and b) we are dropping the right song. The DELETE on /{trashbin uri}/{song id} doesn't provide 2 of the 3 required bits of information, and DELETE /playlist/{playlist id}/{song id}/{index} isn't very RESTful (imo).
deleting songs from a playlist - the way it is worded makes you think you should use DELETE but if I said, deleting words from a blog post you wouldn't think of using DELETE. Use PUT for this operation.
multidimensional stats queries - this one is hard if you don't create some umbrella resource that contains the possible resources that may be returned (and most likely I would just make it multiple calls instead of one)
We haven't publicized the API quite yet, but we would love get feedback from anybody who might be interested in it. Send me an email if you are: twk@audiogalaxy.com
Unfortunately, the vernacular meaning of the word REST is "not SOAP".