How to detect if PS4 is doing playback or running a game or so with php or js. Is there a REST Api or something like that?
This is not possible because there is no open API. You can try to log in with your account into the webpage of the Playstation Network and scrape the content - but that is nothing like a REST API.