I’m just getting started with the IGDB API and I’m trying to get all the data I need for a search result using requests in python. I have the search function working fine, but the API only returns ID values for some elements of the search result and not the actual data, such as for the image cover, genres, or platforms.
Right now I’m trying to extract the image cover url from the API, but when I try the covers endpoint it just seems to be returning the same random images and not an image or images for the game I’m looking for. I’m not sure if I need to specify the image id somehow, but I’ve also tried that and got the same result.
import json
import requests
token = get_token()
client_id = "my id"
headers = {"Client-ID":client_id, "Authorization":"Bearer " + token['access_token']}
game_id = "84920"
params = {"fields":"url", "id":game_id}
response = requests.get("https://api.igdb.com/v4/covers", params=params, headers=headers)
image = json.loads(response.content.decode('utf-8'))
Also tried:
image_id = "134616"
params = {"fields":"url", "image_id":image_id}
response = requests.get("https://api.igdb.com/v4/covers", params=params, headers=headers)
image = json.loads(response.content.decode('utf-8'))
Result: a list of seemingly random image urls, not the image(s) for the game I’m looking for.
TCombu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.