N
N
NOONE2018-08-14 22:35:54
go
NOONE, 2018-08-14 22:35:54

Spotify - getting current track without constant API requests?

Hello, I'm trying to learn GO and in general to strengthen my knowledge of programming, I want to make it possible to get the current playing track from Spotify. They do it upon request.

https://api.spotify.com/v1/me/player/currently-playing

It returns JSON where there is the necessary information, I'm interested in the Artist.
That is, you need to send GET to the API every time to get information about which track is playing, for me it looks at least silly and it seems to me that there is some more elegant way to get this information, i.e. for example, the user changed the track, we climbed for JSON .. the question of how to do this is not clear, I found, for example, a software on the open spaces of Github called Snip, it works approximately according to this principle, after looking at the source codes, as I understand it, there is work with the SPOTIFY process itself on the computer ...
Does anyone have any ideas on how this can be implemented? I would be very grateful for the guidance on the true path!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Vlastovskiy, 2018-08-15
@VlastV

Spotify does not support streaming data, i.e. You can't get a track change event using the API.
Therefore, if you use the API, you have no choice but to poll the currently-playing resource with some frequency allowed for Sprotify.
Snip works with the application and reads data from it, this is not working with the API, and programming is on a completely different level.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question