import requests from PIL import Image response = requests.get("https://yesno.wtf/api") if response.status_code == 200: data = response.json() #print(data) image_url = data["image"] image_response = requests.get(image_url) with open("image.gif","wb") as f: f.write(image_response.content) image = Image.open("image.gif") image.show()