WebSocket API vs. REST API

There are two different APIs with different functionalities!

Should I decide and choose one of the two?
Are there advantages or disadvantages when using one or the other?
Does it make sense in some cases to use both?

Does only REST API support pushNotifications?
I did not found any information about pushNotifications in the documentation of WebSocket API.

you mean :

volumio.local/api/v1/pushNotificationUrls?url=http://192.168.1.33/volumiostatus

Yes! I had this REST API command in mind!
Why isn’t there such functionality in WebSocket API?

That was the reason to ask the other questions.

What do you mean? You normally open a socket connection and “subscribe” to events you want to be notified about. Have a look at the docs, but I believe you are looking for the pushState event.

@ashthespy
I know this documentation! I read it before.
I already used the pushState event … but only together with getState request.

I am a beginner with python and socketio!
I wrongly interpreted the following documentation:

Get Player State

getState

Reply:

pushState
{
  "status": "stop",
  "position": 0,
  ...

I thought the pushState event only occur if I send an getState request to the volumio server.
But this is wrong! pushState event is sent after each change of the state.

Thank you for this hint!
Your answer pushed me in the right direction and I wrote a little test routine in python.
When I changed the state using the browser UI the test routine listed all the state changes :slight_smile: without sending getState requests.