Twitch API: Returning Streamers Currently Played Game Image/Banner [PHP]


I am trying to return the image of the streamers CURRENTLY played game. Is there a proper way to do this via the api.

At the moment i am just getting the name of the game the streamer is currently playing, then concatenating it with the image url.

For example.

$gamename1 = "";
$gamename2 = $game;
$gamename3 = "-340x396.jpg";
$gamename = $gamename1 . $gamename2 . $gamename3;

This is a dirty way of doing it, as the image may not always be there?

You could try using the games search endpoint, docs