Thumbnail urls in helix/users endpoint

So I’m requesting information about streams for a few users via the helix/users endpoint
https://api.twitch.tv/helix/users?client_id=<id>&user_login=<name1>&user_login=<name2>...
Extracting the thumbnail_url with

for(var streamobject of body.data){
     thumbnail_url = streamobject["thumbnail_url"];
     ...
}

works just fine, I get the correct url. But how does the thumbnail storage work in the background? Because when I get the thumbnail_url two days later from the same streamer, then the thumbnail is the same as 2 days ago, even when I restart my bot in between. Shouldn’t the thumbnail change? And if so, I should be able to clear the cache if that’s the problem, or?

Err you’ve called the users endpoint and refer to something in the streams endpoint?

What are you displaying the thumbnail in?

Currently I’m seeing a thumbnail of the format

https://static-cdn.jtvnw.net/previews-ttv/live_user_STREAMER-{width}x{height}.jpg

So it never changes.

So depends what you are doing if this data depends on whats next, based on your post, I had no advice on what to do to fix the issue you are reporting

Oops, my bad. I copied the wrong line :sweat_smile: of course I meant https://api.twitch.tv/helix/streams
I’m using this thumbnail in a Discord embed. The problem I have here is, that the image is the same at any time for a certain streamer. Even when I look at the thumbnail in my browser.
So It’s not a problem per-se, but I wanted to ask if this is the way it has to be. I thought, the image updates on the server when a streamer goes live or something.

There’s your problem. Discord is caching the link/image/preview.

Discord will never bother to go and check if the image actually changed, if it already has it, as it copies a instance of the image to it’s server(s) to avoid IP farming. Among other things

Best solution is to do

for(var streamobject of body.data){
     thumbnail_url = streamobject["thumbnail_url"] . '?rnd=UNIXTIMESTAMP';
     ...
}

Then each time you post to Discord it’s always a new Link.

1 Like

Thanks again :smiley: that solved the problem perfectly