Calling rest API of kodi, using response for a subsequent call

i want to implement a “pause”/“stop” call to kodi. in kodi RPC the call body to use is:
{“jsonrpc”: “2.0”, “method”: “Player.PlayPause”, “params”: { “playerid”: 0 }, “id”: 1}

the problem is, it might not be playerid:0 - can also be 1 (or other id).

using a call body:

{“jsonrpc”: “2.0”, “method”: “Player.GetActivePlayers”, “id”: 1}

returns the active player in json which can be used in the call to PlayPause - but how can i achieve that in home assistant? i thought about python script, but do regular REST calls are supported?

You don’t need to implement this. Just configure the Kodi component. This will give you “pause”/“stop” functionality and you can use the service to do play/pause from automation and so on.

thanks - will check it out