Waiting for Web API commands with side-effects to complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
using the Web API, I noticed that requests to commands with side effects end earlier than the related changes appear. For example, if we call the endpoint Get the User's Queue immediately after Add Item to Playback Queue, we'll sometimes get the state of the queue, in which our item is not yet present.
Consequently, to get the contents of the queue after the addition has fully processed, I have to poll in a loop (with possible backoffs), calling /me/player/queue until my element's uri comes up in the output (which is of course an arbitrary heuristic).
It seems that many endpoints exhibit this "non-blocking" behavior, returning a 2XX status code as soon as the action has been accepted for execution, for example:
- Pause Playback sometimes returns before a call to Get Playback State shows the is_playing property as false,
- similarly Start/Resume Playback for is_playing being true,
- Skip To Next may finish before Get Playback State returns that the new track is already playing.
Such an API design is understandable as it increases API responsiveness and significantly reduces server load. However, it requires additional calls to the API to keep the application in sync with the player.
My question is: do I understand the behavior of the API correctly and do my ways of dealing with the described problems seem reasonable? Have you ever encountered similar issues yourself?
Thanks in advance!
Piotr
- Labels:
-
Discussion
-
Question
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page