Trying to get cover images for a list of games

Avatar image for hellxpress
hellxpress

6

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

I'm new to this, but I've been researching and trying to get things sorted out, but I must be missing something because I'm not getting what I'm expecting.

Objective: Given the name and platform, i'd like to find the cover art for the game

Q1) It doesn't seem like i can do that directly, so I guess I should try for the unique ID of the game first. Is that the best approach?

Q2) When I query for an ID, I can't seem to filter by platform successfully.

http://www.giantbomb.com/api/search/?api_key=APIKEY&format=xml&query=frogger&resources=game&field_list=name,id,platforms&filter=platforms:40

Once I get the ID, I think the hard part is over. I can query for the Image via

http://www.giantbomb.com/api/game/2980/?api_key=APIKEY&field_list=name,image&format=xml

but I really only need the small_url or even the thumb_url.

Q3) Is there a way to only get only that via the filter? I tried image:thumb_url but that didn't work

Q4) I guess fundamentally, I'm not understanding something about the API documentation. I assume if i'm searching, I specify a resource to search within (EX: resources=game) and then I can filter on the fields listed in the documentation. But that doesn't seem to work. What am I missing?

Thanks for your help.

Avatar image for soup_menu
soup_menu

293

Forum Posts

26

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By soup_menu

Q1 & Q2) If I've understood you correctly it should be possible to do this in one step:

https://www.giantbomb.com/api/games/?api_key=APIKEY&field_list=name,id,platforms,image&filter=platforms:40,name:frogger

That will retrieve all games with "frogger" in the name that were released on the 2600, which is apparently "Frogger" and "Frogger II: Threeedeep!"

Q3) To the best of my knowledge the "image" field is an all-or-nothing affair. There are also two things to note about images:

  1. Sometimes you will get absolute URLs and sometimes you will get relative URLs. A fix should be on the way, but it's something to be aware of.
  2. Some images may be missing. It's pretty rare, but it happens.

Q4) If you're only looking for a single resource type I've found that it's generally easier to just filter on the name field rather than use the search endpoint.

Avatar image for hellxpress
hellxpress

6

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

That works pretty well! Thank you very much.

I dont suppose there's a way to get exact matches only? Searching for "portal" instead of frogger yields a lot of matches before you actually get to Valve's Portal.

In the meantime, i'm using limit=1 and correcting the ones that are wrong, but it would be nice to not have to.

Avatar image for vahleticar
Vahleticar

296

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#4  Edited By Vahleticar
Avatar image for soup_menu
soup_menu

293

Forum Posts

26

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@hellxpress: No, I don't believe there is. If you had some additional info to filter by (like release year) you might be able to pare down the results, but I think that's the best you could do.

Since you're firing a request per game it occurred to me that there's something else you might need to be aware of: the API rate limit. It's not mentioned in the documentation, but there's now a limit to how quickly you can query the API. The most recent figure I can find is 400 requests per API key per 15 minute interval (see: GB thread & CV thread). If this is for a personal project then you probably don't need to worry, but if it's something you're going to make widely available you'll most likely want to add some sort of handling.

@vahleticar: :)

Avatar image for hellxpress
hellxpress

6

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

Good point about the release year, that's what I'll do, thanks.

And yeah I got hit by the rate limiter. I finally got the right query and ran it for my entire collection. Then I tweaked it two or three times and stopped getting responses. I figured that's what happened.

Thanks for the help!